Change gRPC-JSON Transcoder Error Response
Title: Change gRPC-JSON Transcoder Error Response
Description: The use of the gRPC-JSON transcoder gives the GRPC an error response.
I wish there was a way to export errors in the same format as HTTP.
{"code":5,"details":[{"@type":"type.googleapis.com/google.rpc.RequestInfo","requestId":"r-1"}]} https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/filters/http/grpc_json_transcoder/v3/transcoder.proto
I want it to be converted the same as the existing response.
The gRPC-JSON transcoder changes the REST request to gRPC, and the response should not be changed from the client's point of view.
It's not clear to me what you mean by "export errors in the same format as HTTP." Can you give an example?
@zuercher
Oh! My explanation is wrong.
It means the same as the json response form when rest.
Envoy's response is json form for gRPC error, so the format is slightly different.
for example
{
"timestamp":1417379464584,
"status":400,
"error":"Bad Request",
"exception":"org.springframework.web.bind.MethodArgumentNotValidException",
"message":"Validation failed for argument at index 0 in method: public org.springframework.http.ResponseEntity<test.User> test.UserController.testUser(test.User), with 2 error(s): [Field error in object 'user' on field 'name': rejected value [null]; codes [NotNull.user.name,NotNull.name,NotNull.java.lang.String,NotNull]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [user.name,name]; arguments []; default message [name]]; default message [may not be null]],
"path":"/testUser"
}
for example 2 (using spring problem details)
{
"type": "about:blank",
"title": "Bad Request",
"status": 400,
"detail": "error msg"
"instance": "/problemDetailTest",
"exceptionClassName": "BlueskyException",
"object": "error object"
"displayableMessage": true,
"errorCode": "error1000"
}
but using gRPC-JSON Transcoder Error Response
{
"code":2,
"grpc-code": "UNKNOWN",
"message": "Validation failed for argument at index 0 in method .....",
"details": [
{
"@type":"type.googleapis.com/google.rpc.ErrorInfo",
"reason": "org.springframework.web.bind.MethodArgumentNotValidException"
"domain": "XXX.XXX.Message"
}
]
}
I think it should be returned in the same form as the existing error response. If the response changes, modifications in the client are inevitable.
Do you have convert_grpc_status enabled? I think the error response format you're seeing is what occurs when that config option is enabled, grpc-status is non-zero, and the grpc-status-details-bin contains a serialized google.rpc.Status protobuf. Looking at the code, it also only applies when no body is returned in the response, so I don't think there's an alternate message that can be rendered.
https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_filters/grpc_json_transcoder_filter#sending-arbitrary-content discusses how to render an arbitrary response. I believe that the grpc status in that case is converted to an HTTP response code.
If you enable convert_grpc_status, it will be converted into HTTP response code as you said.
However, the shape of the body cannot be changed.
This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.
This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted" or "no stalebot". Thank you for your contributions.