fix(go_modules): reconcile go.sum checksums using module graph diffing#15106
fix(go_modules): reconcile go.sum checksums using module graph diffing#15106kbukum1 wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses a Go Modules updater behavior where go get / go mod tidy -e can over-prune /go.mod checksum entries from go.sum for modules unrelated to the update, causing downstream CI to re-introduce the removed lines. It introduces a module graph capture/diff helper (go mod graph) and uses it to selectively restore removed /go.mod checksum lines for unchanged modules.
Changes:
- Add
GoModGraphhelper to capture and diffgo mod graphoutput. - Capture module graphs before/after updates and reconcile
go.sumby restoring over-pruned/go.modchecksum lines for unchanged modules. - Add specs covering checksum restoration behavior and
GoModGraphparsing/diffing.
Show a summary per file
| File | Description |
|---|---|
| go_modules/lib/dependabot/go_modules/file_updater/go_mod_updater.rb | Capture module graphs and reconcile go.sum based on changed module paths. |
| go_modules/lib/dependabot/go_modules/file_updater/go_mod_graph.rb | New helper for capturing/parsing go mod graph and diffing module changes. |
| go_modules/spec/dependabot/go_modules/file_updater/go_mod_updater_spec.rb | New test cases for restoring over-pruned go.sum entries. |
| go_modules/spec/dependabot/go_modules/file_updater/go_mod_graph_spec.rb | New unit tests for GoModGraph.capture and #changed_modules. |
Copilot's findings
- Files reviewed: 4/4 changed files
- Comments generated: 3
be682fd to
a32f1bd
Compare
|
As per our discussion, adding the approach which is a combination of fixes to make sure the issue is resolved mostly: Did anything get removed from go.sum at all? |
|
@kbukum1 We need to debug this line, where the actual file update ( The goal is to inspect whether the output of that
To proceed, we’ll need the customer’s manifest and sum files so we can reproduce the behaviour accurately. |
@thavaahariharangit This covers the exact reproduction steps, why it's intermittent, why debugging a single go get invocation wouldn't have surfaced the issue, and why customer manifest files weren't needed — all points that were raised in your reviews. I had already explained this in our standup and across two PRs (#15094 and #15106), but hopefully having it documented in one place puts these concerns to rest. |
What are you trying to accomplish?
When Dependabot updates Go dependencies, Go tooling (
go get,go mod tidy -e) can over-prune/go.modchecksum entries fromgo.sumfor transitive dependencies unrelated to the update. This causes Dependabot PRs to unexpectedly remove hash entries, leading to CI failures when downstream pipelines rungo mod tidyand detect a diff.The fix captures the module dependency graph (via
go mod graph) before and after the update to determine which modules actually changed. Any/go.modchecksum lines removed for unchanged modules are restored, while legitimate changes from the update are preserved.Fixes #14872
Anything you want to highlight for special attention from reviewers?
A reusable
GoModGraphhelper is introduced for capturing and diffing Go module graphs. This can be used beyond this fix for any future need to understand module graph changes. The reconciliation is scoped precisely — it only restores/go.modchecksum lines for modules whose version did not change in the graph, ensuring we never interfere with legitimate dependency updates including transitive ones.How will you know you have accomplished your goal?
/go.modchecksum lines fromgo.sum.Checklist