-
-
Notifications
You must be signed in to change notification settings - Fork 661
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
go/tools/gopackagesdriver: fix package walk panic if bzlmod enabled #3700
Conversation
With bzlmod enabled, also canonical repository names are enabled. Thus labels from the local repository have to be prefixed with two '@' (in order to refer to the canonical repository name) to match the IDs in the package registry. Also, the result of a bazel query does not return the canonical name of the rules_go repository, but the apparent repository name. Thus, the query for go targets it will not match the stdlib label as constructed with the native.repository_name() rule as injected via x_defs. This fix must be considered as workaround as it leads to a mix of canonical and apparant repository names in the package lists. Once bazel query also supports returning the canonincal repository names, a more correct fix can be applied.
Thanks for sending a workaround. I am working on a full fix based on Bazel 6.4.0 over at #3701. Since 6.4.0rc1 should come out either today or tomorrow, I would like to wait and see whether this fully addresses the issue. If it does, I would slightly prefer to have everyone move over to 6.4.0 instead of adding workarounds - the logic around labels in gopackagesdriver is already pretty complex and doesn't have sufficient test coverage. |
I am definitely in favour of a real and clean fix and agree that yet another badly tested workaround might make it worse. But from my experience, not everyone can immediately jump onto the next Bazel version. That's why I offered this workaround based on v0.41.0 still until your fix is ready to be shipped with the compatibility break. |
I do see value in making this work in the short term. How about the following?
In this way the workaround doesn't become a maintenance problem, but we still have something better to offer users on Bazel < 6.4.0 than "doesn't work, update". |
Sounds good to me 👍 |
Hi @pziggo and @fmeum thanks for working on this issue. I'm on a team currently on 5.4.0 and we won't upgrade soon so this patch will help me.
If you point me to where this should be documented I can submit a PR for that and this could be closed out. |
Btw, I just tried applying this patch in my org's repo and it doesn't seem to totally work around the issue on Bazel 5.4.0 (patched onto
For now we are just using a revert as I mentioned in #3604 (comment) but just wanted to raise awareness that this may not be a perfect workaround. Happy to try and help debug if there is more info I can provide |
Thanks Ian, I also hit the same problem with this patch -- I think it only applies to when bzlmod is enabled which is not enabled in my project. I also tried your sugggestion from #3604 to patch the two reverts, and things are working again for me with 5.4.0 as well. Thank you! When I get some extra time I'll try to add this to documentation in https://github.com/bazelbuild/rules_go/tree/master/docs/go/editors. |
Hi @seanmorton-afs, @ian-h-chamberlain, in fact this patch was created based on my debugging efforts with bzlmod enabled. I didn't even realize back then that there is an issue without bzlmod as well. |
@pziggo If I understand the situation correctly, then:
If that's the case then I think this patch isn't needed anymore. Thanks for working on it though! |
Yes @fmeum that looks correct to me. |
Abandoned as agreed here #3700 (comment) |
❗ Update: This PR has been abandoned as agreed here #3700 (comment)
What type of PR is this?
Bug fix
What does this PR do? Why is it needed?
With bzlmod enabled, gopackagesdriver panics with:
With bzlmod enabled, also canonical repository names are enabled. Thus
labels from the local repository have to be prefixed with two '@' (in
order to refer to the canonical repository name) to match the IDs in
the package registry.
Also, the result of a bazel query does not return the canonical name of
the rules_go repository, but the apparent repository name. Thus, the
query for go targets it will not match the stdlib label as constructed
with the native.repository_name() rule as injected via x_defs.
Since the roots do not match the package IDs, the lookup return
nil
whichleads to a segmentation violation while trying to access attributes from the
structure.
Which issues(s) does this PR fix?
Fixes #3604 #3659
Other notes for review
Tests: TODO
This fix must be considered as workaround as it leads to a mix of
canonical and apparant repository names in the package lists. Once
bazel query also supports returning the canonincal repository names, a
more correct fix can be applied.