-
Notifications
You must be signed in to change notification settings - Fork 4.2k
--incompatible_existing_rules_immutable_view
breaks json encoding of existing_rule/s
objects
#16256
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
Comments
I think a solution would have the following shape:
An alternative would be for |
@brandjon fyi |
After looking at this a bit, We do still want to fix json encoding, however. |
--incompatible_existing_rules_immutable_view
breaks json and proto encoding of existing_rule/s
objects--incompatible_existing_rules_immutable_view
breaks json encoding of existing_rule/s
objects
@comius Is this something you can look into? This is also blocking the 6.0 release. |
@meteorcloudy - I have a fix in review internally |
Bazel 6.0 cut is scheduled on Oct 10th, do you think we can fix this in time? |
I hope to submit the fix this week |
…utable_view to be encoded as json and passed as **kwargs To do so, we make ExistingRuleView and ExistingRulesView implement Map. This requires getting rid of NotRepresentableException in starlarkifyValue (see discussion in bazelbuild#13829) so that the view object's accessors don't throw. And that is, arguably, the correct thing to do: the distinction between returning null for some non-representable attributes vs. throwing an exception for others was entirely artificial. This in turn implies a small change in behavior: now, `existing_rule(x).keys()` will omit all attributes whose values cannot be represented in Starlark. (The old behavior was to allow some such attributes, and throw an exception when their value was accessed.) Fixes bazelbuild#13829 Fixes bazelbuild#16256 PiperOrigin-RevId: 478511532 Change-Id: If0c580a4e4eee1739136ea30eddce9eca71995e3
Originally posted by @dws in #13907 (comment)
If
--incompatible_existing_rules_immutable_view
is set,json.encode
(orencode_indent
) will encode an immutablenative.existing_rule
orexisting_rules
object as an array of field names, instead of a dict (because ourDictLikeView
object is aStarlarkIterable
).proto.encode_text
is worse: it will fail withError in encode_text: [...] got ExistingRulesView, want string, int, bool, or struct
when trying to encode a struct one of whose fields has anexisting_rule
object as value.Although there is a workaround (encode
dict(native.existing_rule("foo").items())
), this is obviously a regression compared to the situation before the flag flip.The text was updated successfully, but these errors were encountered: