-
Notifications
You must be signed in to change notification settings - Fork 49
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
HttpJson UpdateUserRequest's FieldMask is unable to be Unmarshalled #1263
Comments
Error seems to be stemming from this line:
The fullName is found in the list: gapic-showcase/util/genrest/resttools/populatefield.go Lines 251 to 254 in 656e5f4
as google.protobuf.FieldMask .
Value passed in is |
Adding some logging to print out
|
I can reproduce the error using just The "fix" was to wrap the value in escaped double quotes e.g. As such, it sounds like Go's One way to fix this would be to check if the field is explicitly of type |
Thanks @noahdietz! This makes sense. I was able to verify that escaping the value in double quotes works. I just ended up using If I'm understanding this correctly, the fix for this is to check for the type of |
Yeah that works better :)
Yeah...which sucks. We can do that in the meantime, but the discrepancy in serialization behavior is not ideal. Can I ask, what serialization library is the Java implementation using for proto-to-JSON? I think specifically for the code that handles query parameters. |
I just took a look and I believe we have our own internal Proto-to-Json Serializer via ProtoRestSerializer: https://github.com/googleapis/gapic-generator-java/blob/main/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/ProtoRestSerializer.java Query Params set via: https://github.com/googleapis/gapic-generator-java/blob/d831bd29ae171ada8aa7f30724c1ece615e1f844/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/ProtoRestSerializer.java#L150 This is all setup via the ApiMethodDescriptor for each Client (i.e Compliance): https://github.com/googleapis/gapic-generator-java/blob/d831bd29ae171ada8aa7f30724c1ece615e1f844/showcase/gapic-showcase/src/main/java/com/google/showcase/v1beta1/stub/HttpJsonComplianceStub.java#L106-L131 |
Seem to be running into the same issues with Duration and Timestamp as well: |
Ok, thank you that is important, because we can fix those here too. Perhaps a helper function that mutates @vchudnov-g isn't the discrepancy in serialization for these types a little odd? Not sure if Go's impl is too strict, or if Java's is too lax. ESF transcoding doesn't seem to care! |
In the end, we use the |
Indeed @blakeli0 that's what I gathered from the links Lawrence provided. This seems to be yet another discrepancy in how the proto-JSON libraries are implemented across languages. The fact that a value serialized by Java proto library cannot be deserialized by Go proto library makes proto-JSON not language-agnostic like the binary format is. |
@vchudnov-g Wanted to see if you had some thoughts on this |
Apologies for not seeing this issue sooner. I'm looking into this and seeing how to resolve it. I need to investigate more, but I am inclined to believe that Go's implementation is indeed too strict given a related issue with query strings, the parsing of the semicolons (#1255 : the semicolon is no longer a query param separator, so sending it unencoded ought to have it parsed as just another character in the key or value, but Go assumes that one meant it as a separator and thus errors). Let me look some more into this particular error. EDIT: To be clear, the two issues are in two distinct libraries, but they both affect query params, so maybe workarounds for both should occur in the same place. TBD. |
@noahdietz https://go.dev/play/p/Lmk7Vs6KbWF is not reproducing the error for me. The first |
Ah, OK, nm. That has the already fixed code. I expanded the snippet in https://go.dev/play/p/gDWlykyKxA3 to show both the error and the solution. |
Yes! Thank you! You are quick :) |
I am able to reproduce the problem. Command-line repro steps:
I suspect the fix may involve using ParseQuery, though we should also pre-process the query string to deal with unescaped semicolons (#1255). I am still investigating why the failure occurs here for |
Some more information on the cause of this problem. Summary:
So: it does look like Anyway, I think the fix/workaround for Showcase is straightforward now. Expect it shortly. (Though I need to work on some other projects, so wall-time ETA may be O(day).) |
I think it can do this (the first example in https://go.dev/play/p/gDWlykyKxA3 is exactly that), but it cannot deserialize what other language implementations of the same spec i.e. Java's serialized or one more generally, one that is not serialized exactly as its own implementation would serialize it.
Would you like to or shall I? I appreciate all the time you have spent digging into this as our REGAPIC expert :) |
Right, good clarification. I was too hasty in my writing. I can file the bug; that way I'm more likely to notice once it gets fixed. ;-) |
Great thank you :) Happy to review any interim showcase fix too, just assign me as a reviewer. |
TBH, I'm wondering about whether this really is a bug in |
Thanks @noahdietz and @vchudnov-g! |
Java Gapic-Generator is implementing showcase coverage for the Identity client (modeled after golang). Draft PR with the full sample code: googleapis/sdk-platform-java#1431
Relevant Code for the test case:
Results in this error:
Logging the HttpRequest:
The logs seems to show that the updateMask field is encodedproperly as a query param, but Showcase is unable to decode this query param:
Thought this might be an error with Java's HttpJson implementation for FieldMask, but tested this with Java-Scheduler using HttpJson + FieldMask and this works properly.
The text was updated successfully, but these errors were encountered: