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
grpc UNAVAILABLE status returned when calling grpc-json rpc with invalid Number (Long, Integer, ...) #5379
Comments
I think it's the wrong request. To use HttpJsonTranscoding, the HttpRule must be defined.
curl -XPOST -H 'content-type: application/json; charset=utf-8; http://localhost:8080/test/armeria -d '{ client (rest call) -> (in server) grpc transcoding -> (in server) gRPC call gRPC code 14 = The service is currently unavailable. This is most likely a transient condition, which can be corrected by retrying with a backoff. Note that it is not always safe to retry non-idempotent operations. I think it would be good to refer to this. https://github.com/line/armeria/blob/main/grpc/src/test/proto/testing/grpc/transcoding.proto https://learn.microsoft.com/ko-kr/aspnet/core/grpc/json-transcoding-binding?view=aspnetcore-8.0 |
My description was probably not clear enough, sorry for that. The This works:
This doesn't work:
I'm perfectly fine that it doesn't work, because Does it make more sense with those additional details? |
The invalid input causes armeria/grpc/src/main/java/com/linecorp/armeria/internal/common/grpc/GrpcStatus.java Lines 143 to 144 in 7f30250
You can use |
Thank you for your investigation and the workaround! |
|
|
Motivation: - Closes #5379 Modifications: - Add corner case(`InvalidProtocolBufferException`) handling logic that returns `INVALID_ARGUMENT` to give more helpful description to clients. - Modify `rpc EchoWrappers()` in transcoding.proto to accept http-post-binding in order to add integration test for type-mismatched json value - Add unit-test, integration-test Result: - Closes #5379 - Describe the consequences that a user will face after this PR is merged. - User gets `INVALID_ARGUMENT` instead of `UNAVAILABLE` for parsing exception when using `HttpJsonTranscoding`. <!-- Visit this URL to learn more about how to write a pull request description: https://armeria.dev/community/developer-guide#how-to-write-pull-request-description -->
When using
HttpJsonTranscoding
with grpc, if we call an rpc with an invalid value for a number, we get a grpc status UNAVAILABLE and no log, which makes the diagnostic very cumbersome.Exemple:
Create an armeria server with this proto file, enable HttpJsonTranscoding, and call
We get:
Note the 10.12, which is a valid json Number, but can't be parsed to a
Long
.I've tried to check the source code, and I see that a
Long.parseLong
is used, and it seems the NumberFormatException raised is catched here:armeria/grpc/src/main/java/com/linecorp/armeria/server/grpc/HttpJsonTranscodingService.java
Line 572 in 30c9718
still I don't know why it results in a UNAVAILABLE status, but at least it would be nice to be able to log something in such case (or have a custom mapping exception handler).
The text was updated successfully, but these errors were encountered: