grpc/grpc-node

GRPC 2 UNKNOWN error.details always empty string

Kevinyeiress opened this issue · 3 comments

I notice that when I receive a GRPC error code 2 Unknown that the error.details is always empty. Even though there is actual message. When it's any other type of GRPC error code response back (e.g 13 Internal or 14 unavailable) the body of error.details actually has the message. Does anyone know why? Or is this a bug?

Note: when i hit the grpc directly from postman for the error 2 unknown I get a message so i know there definitely is a message. I feel there must be a mapping issue or something
GRPC error 2
{
code: 2,
details: ''",
metadata: Metadata {
internalRepr: Map(5) {
'content-type' => [Array],
'date' => [Array],
'server' => [Array],
'content-length' => [Array],
'x-envoy-upstream-service-time' => [Array]
},
options: {}
}

// GRPC error 16
{
code: 16,
details: 'Login failed. - Unknown client/user/password combination.',
metadata: Metadata {
internalRepr: Map(5) {
'content-type' => [Array],
'date' => [Array],
'server' => [Array],
'content-length' => [Array],
'x-envoy-upstream-service-time' => [Array]
},
options: {}
}

 return new Promise((resolve, reject) => {
   const client = getClient();
   client.getData(request, (error, response) => {
     console.log({ error })
   });
 });

Update: I've discovered what the bug is. It is nothing to do with the GPRC code error type. what i noticed that the error message sent back from server had a double space in front of the message e,g " some error" when the error message isn't trimmed from server side. from the client side we get details: "".

It's discarding the error because error code 16 is not a defined gRPC status code. That's why you're seeing error code 2 instead of 16.

It's discarding the error because error code 16 is not a defined gRPC status code. That's why you're seeing error code 2 instead of 16.

error code 16 is UNAUTHENTICATED GRPC code
https://grpc.github.io/grpc/core/md_doc_statuscodes.html

Sorry, I misunderstood the information in the original post. I'm not sure exactly why a double space in front of the details string would cause this. It could be a header encoding issue on the server or a decoding issue on the client.