-
Notifications
You must be signed in to change notification settings - Fork 112
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
Protobuf: Initializer, getter and setter for optional fields with message subtype should be nilable #966
Protobuf: Initializer, getter and setter for optional fields with message subtype should be nilable #966
Conversation
40acb28
to
32842c9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to get ci passed. Note, this might have side effect on other components that using protobuf(a lot of rbi will be updated). I think making the not nil to nilable should be safe, but maybe worth to run some tests and give other team that use protobuf a heads up?
32842c9
to
f0d649e
Compare
Sorry have been on a burst and then a vacation.
I believe it was just an issue with the pipeline not the branch. Rerunning now.
Not sure what the right move is here. The existing sigs are not accurate. But this is a move from a more strict sig to a less strict sig (from non-nilable to nilable) so I don't foresee it breaking anything. But I guess it could be an issue if people are relying on sorbet to make these non-nilable, but in that case they aren't really using protobuf properly so I am not sure what the remediation is. Maybe @paracycle has an idea? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't verified nullability myself.
@KaanOzkan @paracycle Can we get this merged? This is causing pain for us so we are eager to get this change into a new version of the gem. |
Applications that use this DSL generator may now see |
Motivation
In protobuf, when an optional field has a message subtype it is nilable. Suppose I have some protobuf like:
Primitives like
:string
are not nilable. So the following are invalid:However, submessages are nilable:
Implementation
When assembling the
Field
struct, I check if thedescriptor
is an:optional
and it is a:message
. If it is, I wrap the type inT.nilable()
.Tests
I updated the existing test to reflect this case.