kong
kong copied to clipboard
grpc-gateway forwarding errors
Is there an existing issue for this?
- [X] I have searched the existing issues
Kong version ($ kong version
)
2.7.1
Current Behavior
Grpc server returns error status code, but kong returns 200 OK
Expected Behavior
Returning an INVALID_ARGUMENT grpc status will be translated into the appropriate HTTP status code by Kong
Steps To Reproduce
I have a grpc-kotlin server, with 2 interceptors - one for authentication, and one to catch exceptions and set the status and trailers appropriately. In the case of the authentication interceptor, if I return a status of UNAUTHENTICATED, Kong will translate that correctly to the appropriate HTTP status code (401). But in the case of the Exception interceptor, Kong returns 200 OK regardless of the grpc status code returned. If I use a grpc client (Kreya in my case) all grpc error status codes are returned as expected.
I don't think this is an issue with my code. To me it looks like Kong is not handling the grpc status code correctly in all cases. Perhaps the authentication interceptor works at the early point in the communication than the exception interceptor, and this is why one works correctly and the other not.
Anything else?
Using curl I have observed the grpc status is eventually sent as a header
curl -XGET -i -H "apikey:0HRL2PIcWWVl2VFgZ3LEhmTlqT9HvRNz" localhost:8000/v1/clouds
HTTP/1.1 200 OK
Date: Mon, 21 Feb 2022 14:59:01 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
Access-Control-Allow-Origin: *
grpc-encoding: identity
grpc-accept-encoding: gzip
X-Kong-Upstream-Latency: 10
X-Kong-Proxy-Latency: 33
Via: kong/2.7.1
grpc-status: 3
If this is a bug of grpc-gateway it must be somewhere around: https://github.com/Kong/kong/blob/2.7.1/kong/plugins/grpc-gateway/handler.lua#L100
@halfbaked , could you upgrade kong to latest kong 3.x and try it again?
Hi, I'm facing the same issue. I'm currently on version 3.6.1 and getting HTTP 200 as response even though gRPC server is sending error codes.
Tested this briefly in v3.7.0 and it seems to work OK for me.
@halfbaked @utkarsh-mt We have fixed a few bugs in recent releases. Please try again with the latest release.
Seems to be fixed in 3.7.0