-
Notifications
You must be signed in to change notification settings - Fork 1.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
jsonpb: unmarshal does not properly support null input values #1361
Comments
This looks like a valid regression bug. Can you check with the newer |
Works in |
Looks like this is broken in The This specific case is probably safe to change, since the existing behavior is to incorrectly fail to parse the input, but it's probably not going to be high on the priority list. |
Oh neat, there’s already a somewhat related comment about this bug in the code: Lines 91 to 95 in ae97035
I’ve verified that the code already works as expected if the proto specifies I isolated the buggy code to be here: Lines 337 to 339 in ae97035
All we should need to do is make |
hi @puellanivis, when I debugged this, fd.Enum().FullName() actually returns "undefine" if i recall correctly. Maybe the fd didn't have Enum set correctly. |
🤷♀️ When added it into |
Thanks @puellanivis for confirming. Can you submit this fix for the upcoming release? |
I have not jumped the hoops yet to contribute. 😬 I know they are not big hoops, but I’ve avoided it in order to avoid bureaucracy with my work place to explicitly authorize contributions. |
Thank you for being willing to contribute a fix. Before jumping in, I would wait for @neild to make a call for whether this bug meets the bar for a fix per his earlier comment: #1361 (comment) |
…shal The canonical JSON representation for NullValue is JSON "null". Fixes github.com/golang#1361.
Since the fix is relatively simple and this is unlikely to affect backwards bug compatibility, SGTM. |
Thnx team for the quick fix! |
What version of protobuf and what language are you using?
Version: v1.5.2
Language: Golang
What did you do?
Unmarshal JSON message where input data contain key of type google.protobuf.NullValue and value set to "null"
.proto and test file can be found under https://github.com/jeffrngu/null_value
test JSON object:
{
"parameter": {
"key": "$param",
"null_value": null
}
}
What did you expect to see?
In the test driver, I expect both "key" and "null_value" to be in the un-marshaled object.
This is the behavior with v1.3.2.
What did you see instead?
Only"key" exists in the un-marshaled object
=== RUN TestNullValue
null_value_test.go:28: Failed to unmarshall foo/parameter/null_value: expected: KeyValue_NullValue; got:
--- FAIL: TestNullValue (0.00s)
FAIL
Process finished with exit code 1
Anything else we should know about your project / environment?
No
The text was updated successfully, but these errors were encountered: