Skip to content
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

Non-dependent message is not shown on status details #545

Open
terashi58 opened this issue May 8, 2022 · 4 comments
Open

Non-dependent message is not shown on status details #545

terashi58 opened this issue May 8, 2022 · 4 comments
Labels

Comments

@terashi58
Copy link

Describe the bug

When a gRPC server returns error with own custom messages in status details, evans doesn't display some messages even with --enrich option.
If the message type is defined in dependent proto files from RPC definitions, is it shown. Message types which cannot reach from RPC definitions are not shown.

It happens only when using reflection.
I've confirmed the dangling message is provided as details using another tool https://github.com/fullstorydev/grpcurl.

To reproduce

Here is a Dockerfile to reproduce it: https://github.com/terashi58/grpc-details-test/tree/v0.0.3

$ git clone --branch v0.0.3 https://github.com/terashi58/grpc-details-test.git
$ cd grpc-details-test
$ Docker build . -t grpc-details-test
$ docker run --rm -it grpc-details-test
docker:# tmux
docker:tmux0:# ./bin/server
2022/05/08 07:42:58 server listening at [::]:50051

[Ctrl-b c]
docker:tmux1:# make evans-reflect
echo '{"name":"gopher","error_message":"fail"}' | evans -r cli call --enrich Say


content-type: application/grpc

code: Internal
number: 13
message: "error with details"
details:
  {"@type": "type.googleapis.com/sample.Extension", "message": "fail", "subData": {"extended": "sub"}}
  {"@type": "type.googleapis.com/google.protobuf.Timestamp", "value": "2022-05-08T07:43:42.103828426Z"}

evans: code = Internal, number = 13, message = "error with details"
make: *** [Makefile:13: evans-reflect] Error 1

Summary of the sample codes:

Here is the gRPC definition:

syntax = 'proto3';

package sample;

import "proto/sub.proto";

option go_package = "github.com/terashi58/grpc-details-test/proto;proto";

service Hello {
  rpc Say(SayRequest) returns (SayResponse) {}
}

message Extension {
  string message = 1;
  SubData sub_data = 2;
}

message SayRequest {
  string name = 1;
  string error_message = 2;
}

message SayResponse {
  string greet = 1;
}

And another independent proto file for common error code:

syntax = 'proto3';

package sample;

option go_package = "github.com/terashi58/grpc-details-test/proto;proto";

message ErrorCode {
  string value = 1;
}

And the RPC implementation:

func (s *server) Say(ctx context.Context, in *pb.SayRequest) (*pb.SayResponse, error) {
  log.Printf("Received: %v", in.GetName())
  if msg := in.GetErrorMessage(); msg != "" {
    st := status.New(codes.Internal, "error with details")
    st2, err := st.WithDetails(
      &pb.Extension{Message: msg, SubData: &pb.SubData{Extended: "sub"}},
      &pb.ErrorCode{Value: "XXX-123"},
      ptypes.TimestampNow(),
    )
    if err != nil {
      return nil, err
    }
    return nil, st2.Err()
  }
  return &pb.SayResponse{Greet: "Hello " + in.GetName()}, nil
}

The rpc returns error with the custom sample.Extension, sample.ErrorCode and google.protobuf.Timestamp as status details.
evans shows the sample.Extension and Timestamp only in the details section.

Expected behavior

The non-dependent message is also shown in the details section:

# echo '{"name":"gopher","error_message":"fail"}' | evans -r cli call --enrich Say


content-type: application/grpc

code: Internal
number: 13
message: "error with details"
details:
  {"@type": "type.googleapis.com/sample.Extension", "message": "fail", "subData": {"extended": "sub"}}
  {"@type": "type.googleapis.com/sample.ErrorCode", "value": "XXX-123"}
  {"@type": "type.googleapis.com/google.protobuf.Timestamp", "value": "2022-05-08T07:49:44.516657185Z"}

evans: code = Internal, number = 13, message = "error with details"

Environment

  • OS: Ubuntu 20.04 + debian:bullseye docker image
  • Terminal: iTerm2 + tmux (in docker)
  • Evans version: master branch (823938c)
  • protoc version: 3.20.0
  • protoc plugin version (if you are using):
    • protoc-gen-go: 1.28.0
    • protoc-gen-go-grpc: 1.2.0

Additional context

You can run the sample server in the docker image by docker run -p 50051:50051 --rm grpc-details-test ./bin/server and test from a local evans.

This is an additional bug report branched from #529.

@terashi58 terashi58 added the bug label May 8, 2022
@ktr0731
Copy link
Owner

ktr0731 commented May 10, 2022

Thank you for the issue!
I found the root cause, but it requires some refactoring process. I'll merge some changes before fixing this bug.

@terashi58
Copy link
Author

Thank you for your effort.
I'll wait for the fix.

@ktr0731
Copy link
Owner

ktr0731 commented May 14, 2022

Hi @terashi58.
We submitted a PR that resolves this problem, could you try this one if you have time?

$ go install github.com/ktr0731/evans@7917121

FYI: its PR doesn't contain some required tests yet because it requires changing the testing architecture. So, even if the behavior looks good, it will be a little while before the next release can be made.

@terashi58
Copy link
Author

Thank you @ktr0731!
It looks working well. I built the binary and confirmed that all messages in status details are shown with reflection in both the sample case and my real environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants