-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Build settings defined with allow_multiple = True
cannot pass their default values to transition inputs without also being outputs
#14894
Comments
@gregestren The underlying issue seems to be #13817 and I don't want to make it harder to properly fix that issue by layering another hack on top. I see the following options:
To be honest, I am not particularly happy with either of them. What do you think would be the most maintainable fix? |
I created #14908 with the option I found the least intrusive. Let me know if you prefer a different one. |
Thank you for the prompt fix. I have verified it and it works according to out expectations and solves the problem. |
@bazel-io fork 5.1 |
Starlark transition logic temporarily explicitly sets all input build settings of a transition to their defaults. Since bazelbuild#13971, these values are cleared after the transition. However, since then they have also been subject to type validation, which is not only unnecessary, but also breaks in the special case of a string build setting with allow_multiple. With this commit, input-only build settings are unconditionally stripped from the post-transition BuildOptions and do not undergo validation. This is made possible by a refactoring of `StarlarkTransition#validate` that extracts the validation logic into a separate function and also improves some variable names. Fixes bazelbuild#14894 Closes bazelbuild#14972. PiperOrigin-RevId: 434589143
Starlark transition logic temporarily explicitly sets all input build settings of a transition to their defaults. Since #13971, these values are cleared after the transition. However, since then they have also been subject to type validation, which is not only unnecessary, but also breaks in the special case of a string build setting with allow_multiple. With this commit, input-only build settings are unconditionally stripped from the post-transition BuildOptions and do not undergo validation. This is made possible by a refactoring of `StarlarkTransition#validate` that extracts the validation logic into a separate function and also improves some variable names. Fixes #14894 Closes #14972. PiperOrigin-RevId: 434589143
Description of the problem / feature request:
If the input of a transition contains a build setting specified with
config.string()
that hasallow_multiple
set toTrue
, and the setting is left at its default value, the transition can not considered valid without the setting also being one of the outputs.As of #13971, the validation that is performed after a transition has been applied in
StarlarkTransition::validate()
validates both the inputs and the outputs of a transition. If the inputs include a setting specified withconfig.string()
withallow_multiple = True
, part of the validation will involve verifying that the values corresponding to this setting is alist
. However, when setting thebuild_setting_default
of the setting, it is only possible to specify astring
. Therefore, if the setting retains its default value, the validation of the transition will fail when checking if it is alist
if the transition implementation itself does not alter the value.A workaround for this is to set the input setting as an output, checking if it is a string, and returning the value inside a list if it is. This workaround is undesirable since it would have to be done for every transition that uses the relevant setting as an input, and I imagine that adding this false variation might have a needless impact on performance as well.
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
foo.bzl
BUILD
In this example, running
bazel build :c
causes Bazel to throw an error, but setting any value for //:a other than the default value, e.g.bazel build :c --//:a=something
lets it run as intended.What operating system are you running Bazel on?
Red Hat Enterprise Linux Server 7.9
What's the output of
bazel info release
?release 5.0.0
If
bazel info release
returns "development version" or "(@non-git)", tell us how you built Bazel.N/A
Have you found anything relevant by searching the web?
PR #13971 seems to be where the bug was introduced.
Issue #13817 describes a situation where users would like to be able to set an empty list as the default value of an option with
allow_multiple
set toTrue
.The text was updated successfully, but these errors were encountered: