Repository navigation
feat(backport-fix-imports): rewrite module paths on backports to older module majors - #329
Merged
Merged
Conversation
…failed when the script cannot start
loft-bot
reviewed
Oct 22, 2026
loft-bot
left a comment
There was a problem hiding this comment.
Panel review: 2 blocking, 3 quality notes, 9 lanes.
Blocking concerns
.github/actions/backport-fix-imports/src/fix.py:176: the usage check countsobj.config.Xas a use of packageconfig, so an unused import stays in and breaks the build..github/actions/backport-fix-imports/src/fix.py:321: skipped and failed runs leaveconflicts-remainingempty, so the documented!= '0'gate fires.
What was checked. Checked: correctness, security, test-quality, operability, reuse, architecture, typos, infra (CI workflow), PR metadata. Skipped: dead-code, e2e, gap analysis, entry-point fidelity, layout (nothing deleted, no e2e or Go test files, no linked customer bug, not a restructure).
Quality notes (non-blocking)
- consider:
fix.py:179. Could we keep the backported side's blank lines when merging an import hunk? Dropping them lets gofmt fold stdlib and module imports into one group (reproduced locally), and goimports-style lint flags that. This becomes blocking if the target repo's lint enforces import grouping. - nit:
fix.py:302. Couldgit()name the subcommand instead ofargs[0]? A failed commit currently reportsgit -c failed. - nit:
fix.py:292. Could the warning drop "outside import blocks"? It also fires for YAML files, where import resolution never ran.
Contributor
Author
|
The three quality notes are fixed in 0173056 too: blank lines between import groups are kept, git errors name the real command, and the warning no longer says "outside import blocks". |
vcauesantos
marked this pull request as ready for review
October 22, 2026 17:42
… moves for review
Piotr1215
approved these changes
Oct 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
backport-fix-imports. It fixes Go module paths on a backport branch when the target release line is on an older module major thanmain. Example:loft-enterprisemainis onloft/v5andapi/v5, whilerelease-4.xis still on v4.go.modon both branches. It moves files added under a v5 staging folder, resolves conflicts made only of import lines, and rewrites the paths in the changed.gofiles. Then it pushes one fix commit.reasonoutput says how many files are left for review. The action never fails the job.backport.yaml. That is feat(backport): wire backport-fix-imports behind fix-imports with a sticky pr comment #332, behind a flag.Flow
flowchart TD A[Bot opens a backport PR] --> B{Does main use a newer module version than the release branch?} B -->|No| S[Stop: nothing to fix] B -->|Yes| C[Move new files into the old version's folder] C --> D[Fix conflicts that are only import lines] D --> E[Change v5 import paths to v4 in the changed files] E --> F{Did anything change?} F -->|No| U[Nothing to rewrite] F -->|Yes| G[Format, commit and push one fix commit] G --> H{Any conflicts left in real code?} U --> H H -->|No| Done[PR is ready for review] H -->|Yes| Next[Left for a person]If any step fails, nothing is pushed and the backport PR stays as the bot opened it.
Test plan
make test-backport-fix-imports: 63 pytest tests with throwaway git repos and a local bare remote, no network.actionlint,zizmor,make check-bats-jobsandmake check-docsare clean.loft-enterprisebackports and compared with the merged result:pkg/tenancydoes not exist on 4.12.go veton every package the script changed: 43 had nothing to fix and 9 got a fix commit. None of the script's changes caused a compile error. In 3 of the 9,go vetstill failed on code that needs something missing on the older branch. That is a real code change, left for a person.loft-enterprisewith five backports, script and AI pass together: see feat(backport): run backport-fix-imports with an ai pass gated on go vet #330, section Real run on loft-enterprise.Related to DEVOPS-1648
Related to DEVOPS-1671