-
Notifications
You must be signed in to change notification settings - Fork 651
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
Set defaults to false for loader definitions #1867
base: master
Are you sure you want to change the base?
Conversation
There isn't much value in having defaults set for descriptors What's more it causes issues when using those descriptors with protobufjs Descriptors with oneofIndex: 0, cause issues when they aren't part of a oneof
|
Those options aren't used at all when loading descriptor objects in as package definition objects, so this issue with |
They are used in |
The Protobuf.js function you pointed to is |
Ah right, I see what you mean, nothing calls that in that chain. That chain is purely for the creation of the descriptor objects that exhibit this problem. So, when using a descriptor that has been created using that chain of functions (i.e. any of the exported helpers from this file) the protobufjs |
Are you talking about taking that object output by proto-loader and passing it directly to Protobuf.js yourself? If so, that was never an intended use case of this API. Those message definition and enum definition objects have a structure specified in this proposal. In particular, the |
I actually read the opposite to be true (by default) in the linked Google page regarding the canonical JSON mapping:
I understand that it wasn't intended but as per that proposal it might be nice to support it given that the defaults would allow this (from my reading)? I'm assuming this is why protobufjs fails to handle this case, because it does assume defaults will not be present in the JSON mapping: but that's just speculation! |
I see. I did have that backwards. In that case I think I can accept this change. You'll still need to sign the CLA. As far as I know, Protobuf.js APIs are not generally concerned with the canonical JSON mapping. I assume it just doesn't account for representing the object with defaults. |
Excellent thanks 👍 I have gone through and signed the CLA, do I need to force push a slight change to this branch for it to retrigger? |
Looking at the CLA bot comment again, it looks like the problem is that the commit is using an email address that is not associated with your GitHub account. I think you can fix it by either adding that email address to your GitHub account, or modifying the commit with the email address that you already use with GitHub. |
This usage of defaults causes issues when using descriptors with protobufjs. Descriptors that default to oneofIndex: 0 cause issues when they aren't actually part of a oneof. Specifically here:
https://github.com/protobufjs/protobuf.js/blob/95b56817ef6fb9bdcb14d956c159da49d0889bff/ext/descriptor/index.js#L218-L219
where it assumes that if there's a
oneofIndex
then that is a valid index into theoneofDecl
array. I could have changed the logic there but this feels more "upstream" and there doesn't seem to be a need fordefaults
to betrue
regardless of this issue withprotobufjs
.