-
Notifications
You must be signed in to change notification settings - Fork 913
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
Incorrect grpc status code on exceeding max response limit #5818
Comments
ikhoon
added a commit
that referenced
this issue
Jul 26, 2024
… is exceeded (#5824) Motivation: If a request or response message exceeds the maximum allowed message length, `RESOURCE_EXHAUSTED` status should be returned to the client. In `UnaryServerCall`, an exception raised `ArmeriaMessageFramer` is not handled by `GrpcExceptionHandlerFunction`. As a result, the exception is directly passed to the HTTP level `ServerErrorHandler` and a proper gRPC status is not delivered to the client. While I was fixing the bug, I found a lot of code that calls `generateMetadataFromThrowable()` and then `fromThrowable()`. As the same pattern was used repeatedly, I also refactored `GrpcExceptionHandlerFunctionUtil` to return `StatusAndMetata` instead. Modifications: - Apply `GrpcExceptionHandlerFunction` when an exception is raised in `UnaryServerCall.doClose()` - Refactor `GrpcExceptionHandlerFunctionUtil` and its calling site. - Add `InternalGrpcExceptionHandler` to wrap `GrpcExceptionHandlerFunction`. - Remove the incorrect `@Nullable` annotation for `GrpcExceptionHandlerFunction`. - Remove `ServerStatusAndMetadata.setResponseContent()` and use `RESPONSE_CONTENT` property for simpliciy. Result: - `GrpcService` now correctly returns `RESOURCE_EXHAUSTED` when a response message exceeds the maximum allowed length. - Closes #5818
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There seems to be an issue with the way gRPC status codes are handled when the max response limit is exceeded.The following line:
armeria/grpc/src/main/java/com/linecorp/armeria/server/grpc/UnaryServerCall.java
Line 153 in c208353
could throw
AmeriaStatusRuntimeException
when the max response limit is set. The response future is then completed with that exception directly, bypassing the exception handler. This is different from exceptions occurring within the handler, which are transformed into StatusRuntimeException in theclose
method:armeria/grpc/src/main/java/com/linecorp/armeria/internal/server/grpc/AbstractServerCall.java
Lines 216 to 221 in 74f6e3c
As a result, the expected gRPC status code
RESOURCE_EXHAUSTED
is not being set when the response message exceeds the limit. Instead, I observe that the status code returned isINTERNAL_ERROR
.The text was updated successfully, but these errors were encountered: