Skip to content

Fix indirect resolver to respect replace directives#21

Open
kbsteere wants to merge 3 commits intochainguard-dev:mainfrom
kbsteere:fix-indirect-resolver-replace
Open

Fix indirect resolver to respect replace directives#21
kbsteere wants to merge 3 commits intochainguard-dev:mainfrom
kbsteere:fix-indirect-resolver-replace

Conversation

@kbsteere
Copy link
Contributor

@kbsteere kbsteere commented Mar 2, 2026

The indirect dependency resolver was recommending parent package bumps that would break builds when the user's go.mod contains replace directives. This fix adds replace directive awareness by skipping dependencies with replace directives, checking for version conflicts when evaluating parent versions, and handling v0.0.0 placeholders used by k8s.io/kubernetes for internal replace directives. Now omnibump correctly recommends direct bumps instead of problematic parent bumps when replace directives are present.

@kbsteere kbsteere force-pushed the fix-indirect-resolver-replace branch from a1c8cd0 to ee1e9c0 Compare March 2, 2026 21:43
Signed-off-by: Kyle Steere <kyle.steere@chainguard.dev>
@kbsteere kbsteere force-pushed the fix-indirect-resolver-replace branch from ee1e9c0 to dbad3d6 Compare March 2, 2026 23:06
@kbsteere kbsteere requested a review from a team March 2, 2026 23:07
@kbsteere kbsteere enabled auto-merge (squash) March 2, 2026 23:07
…lace conflict detection

- Remove duplicate hasReplaceDirective from indirect_resolver.go; the canonical
  version already exists in golang.go (landed via chainguard-dev#27). Having both in the same
  package caused a compile error on merge.
- Add nil guard to golang.go's hasReplaceDirective to match the defensive check
  that existed in the removed duplicate.
- Fix hasReplaceConflicts to treat local path replaces (empty version string) as
  a conflict; semver.Compare returns 0 for non-semver strings so they were
  previously silently ignored.
- Simplify hasReplaceConflicts: remove conflictCount accumulator in favour of
  early return on first conflict; convert log.Info per-conflict calls to
  clog.DebugContext per go-standards.
- Add capacity hint to replaceMap make() call.
- Fix nil dereference in analyzer.go: guard Dependencies map lookup and
  Metadata field before writing foundInModules.
- Replace context.Background() with t.Context() in replace directive tests.
- Update libp2p test fixture version v0.47.0 -> v0.48.0 to match current proxy.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants