-
Notifications
You must be signed in to change notification settings - Fork 15.6k
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
protoc doesn't allow some field names due to bad json_name logic #7192
Comments
I think this is related to #5063, at least in the fact that they are both related to how In fact, adding a
|
FYI, @dsnet, it looks like |
@jhump I think there may be good reason for enforcing that the names are unique without considering custom JSON names. I haven't thought about this in a while but I believe there's a technical reason for why FieldMasks can't use custom JSON names and therefore need to use either the original field name or the default JSON name. |
If that's really the case then the error message should be improved (since it is talking about JSON names and makes no caveat about why the option is ignored). Further this constraint should be clearly documented. I don't see any documentation for it, but it deserves to be called out in the main proto3 doc page. |
@acozzette, you commented above that protoc may need to require that the camel-case version of each field is unique (not just JSON name). But what about the case described in the issue description? It complains even if the camel-case for one field differs from another by only case. Is that also related to field masks? Or is that possibly a bug? |
We are going to shortly release updated json support, that we ought to be able to work in this fix as well |
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment. This issue is labeled |
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please reopen it. This issue was closed and archived because there has been no new activity in the 14 days since the |
This is still a problem. As far as I can tell from the proto3 language guide, And yet you get this nonsensical error
This would only be a valid error for fields like |
What version of protobuf and what language are you using?
Version: 3.11.3
Language: none (using
--descriptorset_out
)What operating system (Linux, Windows, ...) and version?
Mac OS X
What runtime / compiler are you using (e.g., python version or gcc version)
No runtime; just using the
protoc
binaryWhat did you do?
I tried to compile the following proto file:
I used the following command:
What did you expect to see
I expected this to work and to produce a
test.protoset
file.If I remove the conflicting fields and generate this in isolation, the resulting
json_name
fields in the output descriptors are all different -- so there's no actual conflict. For reference:abc
becomes JSON name ofabc
abc_def
becomes JSON name ofabcDef
__a__b__c
becomes JSON name ofABC
_abc_def
becomes JSON name ofAbcDef
What did you see instead?
The command fails with the following error:
It appears that it is using a case-insensitive comparison to determine if there is a conflict. But I believe that is wrong for a couple of reasons:
The text was updated successfully, but these errors were encountered: