fix(go_modules): preserve unrelated go.mod checksums in go.sum#15056
Closed
v-HaripriyaC wants to merge 1 commit into
Closed
fix(go_modules): preserve unrelated go.mod checksums in go.sum#15056v-HaripriyaC wants to merge 1 commit into
v-HaripriyaC wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts the Go modules updater to avoid accidentally dropping go.mod checksum entries from go.sum for modules that aren’t part of the requested update, aligning Dependabot’s output more closely with typical go mod tidy behavior.
Changes:
- Add
reconcile_go_sumto re-add removed/go.modchecksum lines for modules not being updated, then re-sort the mergedgo.sum. - Update
update_filesto returngo_sumonly when present (viaHash#compact). - Add specs covering restoration of an unrelated
/go.modchecksum line and ensuring updated dependencies’ removed lines are not restored.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| go_modules/lib/dependabot/go_modules/file_updater/go_mod_updater.rb | Adds go.sum reconciliation logic and adjusts updated file return shape. |
| go_modules/spec/dependabot/go_modules/file_updater/go_mod_updater_spec.rb | Adds regression coverage for restoring unrelated /go.mod checksum lines. |
216a158 to
7e00ddf
Compare
0a611c6 to
4635ad8
Compare
fbfb8a7 to
6fc36cd
Compare
72cbc3c to
e4172a4
Compare
e4172a4 to
2612f50
Compare
384d924 to
4c871f2
Compare
4c871f2 to
ab7430e
Compare
When go get updates a dependency, it may remove /go.mod checksum lines from go.sum for unrelated modules that are still in the dependency graph. This causes noisy diffs that go mod tidy would revert. Add reconcile_go_sum to restore missing /go.mod checksum lines when: - The line belongs to a module not being updated - The same module+version still has a zip hash entry in the updated file The restore uses Dependabot::GoModules::Version for semver-aware sorting to produce canonical go.sum ordering. When no lines need restoring, the updated go.sum is returned unchanged to avoid unnecessary rewrites. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ab7430e to
29b0fb1
Compare
Contributor
Author
|
added repo to reproduce the issue with and without the fix https://github.com/dsp-testing/removes-hashOfGomod-goSum-issue/blob/chp/removes-hashOfGomod-goSum-issue/ |
thavaahariharangit
requested changes
May 19, 2026
Contributor
Author
|
fixed as part of #15106 |
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.
When Go tooling (go get, go mod tidy) runs during a dependency update, it can prune go.mod checksum entries for indirect/transitive dependencies that aren't strictly needed for building. This causes Dependabot PRs to unexpectedly remove hash entries from go.sum that go mod tidy would keep.
Add reconcile_go_sum to detect go.mod checksum lines that were removed for modules NOT being updated, and restore them in sorted order.
Fixes #14872
What are you trying to accomplish?
Anything you want to highlight for special attention from reviewers?
How will you know you've accomplished your goal?
Checklist