Skip to content

[gRPC] How to correctly transmit error details to client with gRPC-JSON transcoding? #49196

@Sayan751

Description

@Sayan751

Discussed in #49179

Originally posted by Sayan751 July 3, 2023
I have a gRPC service with JSON transcoding enabled. An endpoint of the service throws RpcException with same status code but different metadata. Examples:

throw new RpcException(new Status(StatusCode.InvalidArgument, "Whatever1"), new Metadata
{
    { "Code", Errors.Error1.ToString() }
});

throw new RpcException(new Status(StatusCode.InvalidArgument, "Whatever2"), new Metadata
{
    { "Code", Errors.Error2.ToString() }
});

Whoever, when I am making an HTTP call to the service, then I am getting the following:

{
  "code": 3,
  "message": "Whatever1",
  "details": []
}

I expected the trailers to appear in the details array. Am I missing something here? At the end, I need a way to differentiate between the two errors with the same status code. Is that possible?

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-grpcIncludes: GRPC wire-up, templates

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions