Fix package name collision when two packages share the same base name#111
Merged
Fix package name collision when two packages share the same base name#111
Conversation
When two packages have the same last path component (e.g. sub-a/shared and sub-b/shared both resolve to "shared"), GetReference was using filepath.Base(pkg) as the lookup key, causing the second type to silently overwrite the first in prog.References. The fix adds a collision check before storing: if the key already exists for a different package, a numeric suffix is appended (shared.Request2, shared.Request3, …) to produce a unique key. Repeated calls for the same colliding package reuse the existing suffixed key. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Coverage Report for CI Build 25377765942Coverage decreased (-0.1%) to 53.04%Details
Uncovered Changes
Coverage Regressions7 previously-covered lines in 1 file lost coverage.
Coverage Stats
💛 - Coveralls |
…xity GetReference exceeded the gocyclo threshold of 65 (was 68). Extracting the field-whitelist processing block into its own helper brings it back under the limit without changing behaviour. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
twariel
approved these changes
May 5, 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
sub-a/sharedandsub-b/shared),GetReferencewas computing the same lookup key (shared.Request) for both, causing the second definition to silently overwrite the first inprog.References.shared.Request2,shared.Request3, …) to produce a unique key. Repeated calls for the same colliding package correctly reuse the existing suffixed key.shared, verifying their definitions remain distinct in the generated output.Test plan
go test ./...passespackage-name-collisionfixture confirmsshared.Requestandshared.Request2resolve to the correct, separate struct definitions🤖 Generated with Claude Code