-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Breaking change in Bazel CQuery due to Starlarkification of providers #20473
Comments
cc @gregestren |
@guw did you already bisect which change caused this change in behavior? |
Maybe this is just some breaking change after we starlarkifying |
Yes, this will be a side-effect of moving native providers to Starlark. The Not sure anything else would make sense for identifying a provider written in Starlark. So we should just add this to the release notes as a breaking change. |
Thanks for confirming!
Please do! |
I think that would be super helpful (although inconvenient). Would it be possible to provide a different function/way? |
I’m not happy with this, but this is WAI and will change at least one more time when the rules are moved out of builtins. Making it same as before would require adding hacks to the implementation. Any bzl file that needs a provider, has to import it via a load. This is also going to change from a global symbol for even JavaInfo to a load from rules_java. Starlark query expressions are the only location where a provider can’t be loaded and you refer to it by a string. For correctness, also bzl file needs to be in the string (otherwise the map might not have unique keys). Possible workaround in user space is to either use both strings that represent the provider. Or maybe even filter the map for keys that end with JavaTolchainInfo |
@gu2 can you think of any clean user experience that wouldn't have the ambiguity of filtering the map? (i.e. risk of resolving to the wrong |
It depends on how real ambiguity is @gregestren. It would love to have a Perhaps there is a better way. The full query I am doing is:
I would have to do the filtering three times in a single line. I don't think All I want is identify JAVA_HOME and source and target version so I can setup the IDE properly. Perhaps there is a better way to query this? |
Is it necessary for the starlark code to be specified on the command line? If not, you could use |
Oh, that looks doable. BTW, that example doc needs fixing as well:
It should mention the specifics around keys instability from Bazel version to version. |
This adapts to breaking changes in Bazel 7 while maintaining backwards compatibility to Bazel 6.x. See bazelbuild/bazel#20473 for details.
Thanks @hvadehra. Using |
so the issue remains open, does it mean it will be fxied at some point, or we should treat |
Yes, for now that will the key. As noted in #20473 (comment) it will change (at least) once more when the java rules move out of |
Description of the bug:
The following cquery no longer works with Bazel 7:
It looks like that
providers(target)["JavaToolchainInfo"]
needs to be replaced withproviders(target)['@@_builtins//:common/java/java_toolchain.bzl%JavaToolchainInfo'].source_version
but it feels odd to require this verbosity now. Especially the label syntax looks subjective to further changes. It should be possible to select a provider without relying on the location.What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
run the query
Have you found anything relevant by searching the web?
https://bazelbuild.slack.com/archives/CDCE4DFAP/p1702038149142419?thread_ts=1701990164.906629&cid=CDCE4DFAP
Any other information, logs, or outputs that you want to share?
This needs to be documented. Ideally all those queries would continue to work, though.
The text was updated successfully, but these errors were encountered: