Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Bazel module resolution regression in go_deps #1966

Merged
merged 2 commits into from
Oct 25, 2024

Conversation

fmeum
Copy link
Member

@fmeum fmeum commented Oct 23, 2024

What type of PR is this?

Bug fix

What package or component does this PR mostly affect?

go_deps

What does this PR do? Why is it needed?

2a65ce8 made it so that Bazel modules would no longer override Go modules if their versions don't match exactly.

Also do not report version mismatches for overridden Bazel modules.

Which issues(s) does this PR fix?

Fixes #

Other notes for review

@fmeum
Copy link
Member Author

fmeum commented Oct 23, 2024

@Buzz-Lightyear Could you review this?

2a65ce8 made it so that Bazel modules would no longer override Go modules if their versions don't match exactly.

Also do not report version mismatches for overridden Bazel modules.
Copy link
Contributor

@Buzz-Lightyear Buzz-Lightyear left a comment

Choose a reason for hiding this comment

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

LGTM

@fmeum fmeum merged commit 84320ee into master Oct 25, 2024
16 checks passed
@fmeum fmeum deleted the tweak-version-resolution branch October 25, 2024 16:24
# Only use the Bazel module if it is at least as high as the required Go module version.
if path in module_resolutions and bazel_dep.version != module_resolutions[path].version:
# Do not report version mismatches for overridden Bazel modules.
if path in module_resolutions and bazel_dep.version != _HIGHEST_VERSION_SENTINEL and bazel_dep.version != module_resolutions[path].version:
outdated_direct_dep_printer("\n\nMismatch between versions requested for module {module}\nBazel dependency version requested in MODULE.bazel: {bazel_dep_version}\nGo module version requested in go.mod: {go_module_version}\nPlease resolve this mismatch to prevent discrepancies between native Go and Bazel builds\n\n".format(
Copy link

Choose a reason for hiding this comment

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

Is it expected that this DEBUG print also happens when the dep in go.mod is indirect?

To give a concrete example, we have cel.dev/expr v0.18.0 // indirect in go.mod, and 0.15.0 in bazel mod graph which is a transitive dep of grpc-java shown as following, so neither of them is a direct dep.

├───grpc-java@1.67.1
   ├───cel-spec@0.15.0

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd say that's desired behavior as it gives you the opportunity to explicitly add a replace directive for the version you'd like, if you so chose.

Copy link

Choose a reason for hiding this comment

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

This check makes sense. I was just wondering whether this function outdated_direct_dep_printer was designed for this purpose.

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.

3 participants