-
Notifications
You must be signed in to change notification settings - Fork 69
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
ensure fields are JSON encoded correctly #1407
Comments
@vchudnov-g I dont understand this request. Python is a dynamic language, thus it does not check for type and it is expected. Plus the json serialization/deserialization is in protobuf code, and it seems to be a conscious decision made by protobuf team to not do static type check during serialization. This request seems to be agains the whole architecture of protobuf and gapic data model and the dynamic nature of Python language. I'll close this request for now. Feel free to reopen, but please provide more justification why you expect static type analysis on the client side for Python. Another thought here: even if we choose to do something about it, it would be super hard, and would require change in protobuf probably, which does not seem feasible. |
I also checked the serializaiton process on talent-v4 API:
This produces the following json:
Booleans are serialized properly. this must be the case, otherwise Compute client would be completely broken (there are > 300 boolean fields in compute surface) |
I can confirm I get the same error as Victor when testing on showcase The bug is somewhere in these lines taken from the generated
So query_params are wrong. I'll try to play with transcoding logic to reproduce this. Added integration tests in #1424. |
Sorry, just saw that you closed this, @vam-google . Reopening with clarifications: I don't "expect static type analysis on the client side". What I do expect is the JSON encoding to be correct, and it seems like the booleans get capitalized on the query params. You mention good points that we're serializing correctly in the request bodies, so something must be going on in the query params. |
The issue is
Technically There are two places to do that:
I'm leaning towards 1) because currently issue specifically happens in one concrete example, and @vchudnov-g let me know your thoughts. |
I think
That said, please wait a bit to do non-trivial changes because of the following: this is the query string, not the request body, so technically it is not JSON. Let me check whether Google servers can take a capitalized bool in the query string; if they can, then maybe we can do nothing on the client side. If they can't, then yes, I think we should fix the WDYT? |
It's a part of So we should open an issue in their repo... |
OK, I looked at the code, and it seems like the request call eventually winds up in yet another library, here, which expects "a dictionary of strings". So I'm assuming that means If we want to be strict about backwards compatibility, we can add an optional parameter Thoughts? Do you want to make this change, @atulep or do you want me to? I know you've got a bunch of other things on your plate as well, and I don't mind getting experience on the other repos. |
FWIW, Google servers can take capitalized booleans, but I still think we should fix this for cross-language consistency, which immediately affects Python. |
For reference, the above fix was not quite correct. The correct fix was implemented in #1447 |
The best way of verifying correct behavior is probably to implement integration tests against the Showcase compliance suite, which test various data types.
Context: boolean fields seem to be not serialized correctly. I assigned
True
to a proto.Field as a kwarg in the message constructor:and the Showcase server returns with an error. The Showcase server logs read:
which is mostly due to True being sent capitalized rather than lower-cased, as the JSON spec requires.
This is a blocker for launching REGAPIC.
The text was updated successfully, but these errors were encountered: