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 autoboxing of wrapperspb types #100

Merged
merged 1 commit into from
Sep 8, 2021
Merged

Conversation

seena-stripe
Copy link
Collaborator

Summary

Autoboxing of wrapperspb types was only partially working, allowing msg.f_StringValue = "something" to typecheck (typechecking was done by valueFromStarlark which does the autoboxing) but the assignment was actually assigning "something" a string into the internal fields map. Then when access happens, msg.f_StringValue.value fails because msg.f_StringValue == "something" and does not have .value

This PR removes maybeConvertToWrapper from valueFromStarlark so typechecking fails if the conversion has not been explicitly done before assignment. The conversion is moved earlier into protoMessage.SetField where the list/dict conversions are done.

As an extra fun, there was existing support for converting ["s1", "s2"] into [StringValue{value: s1}, StringValue{value: s2}] which breaks the list assignment semantics. In this case the assignment mutates like map do for None, though it could alternatively copy if we want.

Longer term, I'd really like to get rid of this autoboxing behavior, its convenient but adds a lot of complexity

Tests

I added tests to protomodule_message_test

Copy link
Collaborator

@kathleen-stripe kathleen-stripe left a comment

Choose a reason for hiding this comment

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

LGTM except for possibly one comment - feel free to send back to me for re-review if no changes are needed

@seena-stripe seena-stripe merged commit cc2f2d0 into trunk Sep 8, 2021
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.

2 participants