Skip to content

fix(gazelle): Correctly resolve deps that have top-level module overlap with a gazelle_python.yaml dep module#2160

Merged
aignas merged 1 commit intobazel-contrib:mainfrom
alex-torok:undo-change-to-looking-up-third-party-dep
Aug 28, 2024
Merged

fix(gazelle): Correctly resolve deps that have top-level module overlap with a gazelle_python.yaml dep module#2160
aignas merged 1 commit intobazel-contrib:mainfrom
alex-torok:undo-change-to-looking-up-third-party-dep

Conversation

@alex-torok
Copy link
Copy Markdown
Contributor

In #2048, FindThirdPartyDependency was updated to walk up the module import path to try to find a match in gazelle_python.yaml. This is unnecessary, as the main resolve loop will accomplish the same task.

Additionally, the change broke the ability to configure a more specific resolve override or resolve more specific indexed libraries.

For a real-world example of where this is a problem, pytype has a third_party module at its top-level. In a repo that also has a third_party directory, we can no longer resolve our indexed libraries in third_party. When the resolve loop tried to resolve third_party.foo.bar, FindThirdPartyDependency will immediately match third_party and not give the resolve loop a chance to look in the rule index for third_party.foo.bar.

The same issue appears for providing overrides that are more specific (see the updated testcase).

This PR reverts the change to FindThirdPartyDependency and updates the testcases to ensure that we can still resolve specific indexed packages, explicit resolve overrides, and third party modules even when there is an overlap in the top-level module name.

@alex-torok alex-torok requested a review from f0rmiga as a code owner August 27, 2024 20:38
@alex-torok alex-torok changed the title fix(gazelle): Correctly resolve deps that have top-level module overlap with a third party dep module fix(gazelle): Correctly resolve deps that have top-level module overlap with a gazelle_python.yaml dep module Aug 27, 2024
@alex-torok
Copy link
Copy Markdown
Contributor Author

FYI @aignas since you reviewed #2048.

@alex-torok alex-torok force-pushed the undo-change-to-looking-up-third-party-dep branch from ca81c7f to 3a25f13 Compare August 27, 2024 20:41
@alex-torok alex-torok force-pushed the undo-change-to-looking-up-third-party-dep branch from 3a25f13 to 3804bbb Compare August 27, 2024 20:41
Copy link
Copy Markdown
Collaborator

@aignas aignas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@aignas aignas added this pull request to the merge queue Aug 28, 2024
Merged via the queue into bazel-contrib:main with commit 2a5ba18 Aug 28, 2024
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