Fix go modules error in package details fetcher due to subpath issue#15096
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes Go Modules PackageDetailsFetcher behavior for dependencies specified as sub-package import paths (e.g., .../cmd/tool), by attempting to resolve available versions from progressively shorter paths when the initial go list -m -versions query yields no versions.
Changes:
- Refactors version retrieval into
fetch_module_versionsand introducesresolve_module_versions_from_subpathfallback logic. - Adds specs covering sub-package fallback, module-root behavior, and the “no versions anywhere” case.
Show a summary per file
| File | Description |
|---|---|
| go_modules/lib/dependabot/go_modules/package/package_details_fetcher.rb | Adds version-fetch helper and subpath-to-module-root fallback logic. |
| go_modules/spec/dependabot/go_modules/package/package_details_fetcher_spec.rb | Adds unit tests for the new fallback behavior and edge cases. |
Copilot's findings
- Files reviewed: 2/2 changed files
- Comments generated: 3
thavaahariharangit
approved these changes
May 21, 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.
What are you trying to accomplish?
Fixes #15027
Go-based pre-commit
additional_dependenciesthat use sub-package paths (e.g.,github.com/wasilibs/go-shellcheck/cmd/shellcheck@v0.10.0) fail to find newer versions. ThePackageDetailsFetcherpasses the full package path togo list -m -versions -json, but this command expects a module path, not a package path. The Go proxy returns 404 for the sub-package path, causing Dependabot to incorrectly report the current version as the latest.This change adds a fallback mechanism: when no versions are found for the full path, progressively shorter paths are tried (e.g.,
github.com/wasilibs/go-shellcheck/cmd→github.com/wasilibs/go-shellcheck) until the actual module root is found.Anything you want to highlight for special attention from reviewers?
nil), so existing behavior for valid module paths is unchanged.github.com/owner/repo), which is the standard for well-known hosts. This prevents unnecessary queries for paths that can't be valid Go modules.How will you know you've accomplished your goal?
package_details_fetcher_spec.rbpass.Checklist