-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
fix(grpc-gateway): handle null values in payload #10687
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide a useful summary in your pull request description. What is the problem, what is the cause, what is the solution. It can be short, but it needs to describe what the change is about.
@@ -82,6 +82,8 @@ | |||
[#9903](https://github.com/Kong/kong/pull/9903) | |||
|
|||
### Fixes | |||
- **gRPC gateway**: Fix an issue where handling `null` in JSON payload | |||
[#10687](https://github.com/Kong/kong/pull/10687) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please be specific about what has been fixed. "Fix an issue" is not helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated, PTAL
updated |
@hanshuebner Could you please cherry pick this change into EE? |
@sabertobihwy does the fix accepts the JSON payload with null? or it will just throw an error says that "Null in Json"? |
it does't convert null in JSON payload to a string value, and will return |
But that doesn't fix the actual problem right? |
The error occurred due to a type matching error in |
@arunpk-zageno This PR has fit my suggestion. After patched this PR, Kong can not return |
Got it @attenuation , And thanks @sabertobihwy for the fix. Which version I could expect this fix? |
I think it will release in 3.3 |
Sorry for iterative question, when can we expect the release? |
Expected time is May 15th |
https://konghq.atlassian.net/browse/KAG-5777 (cherry picked from commit #13846) Co-authored-by: Chrono <chrono_cpp@me.com>
Summary
#10658
Problem: When using the grpc-gateway plugin, if there is a null in the payload of the client request, such as:
an error will be thrown:
bad argument #2 to 'encode' (string expected for field 'object_type', got userdata)
, causing Kong to return 500 to the client, which is an error because Kong did not handle this edge case.Cause: In JSON,
null
is valid and legal. However, after this payload is decoded by cjson,null
actually becomescjson.null
in Kong, and its data type isuserdata
, but thename
is defined as a string type in the proto file.Solution: Use
pcall
to wrap thepb.encode
function call, record the error log, and convert the error into a common client parameter error.Checklist
Full changelog
Issue reference
Fix #[issue number]