Closed asido closed 2 years ago
yarpcerrors.WithDetails() expects the details as a byte array so depending on the encoding scheme, the correct marshled byte array has to be provided here.
In this case, string bytes were directly provided which can not be unmarshled through proto, hence we see the error from proto during unmarshling.
Try passing a valid proto byte array and it should work fine. For example, I tried the following and works fine:
WithDetails(types.StringValue{Value: "abc"}.XXX_unrecognized)
However, for a better readability I strongly recommend to use protobuf.WithErrorDetails()
for protobuf error.
Example:
HandlerSpec: yarpctransport.NewUnaryHandlerSpec(
UnaryHandlerFunc(
func(context.Context, *yarpctransport.Request, yarpctransport.ResponseWriter) error {
return protobuf.NewError(yarpcerrors.CodeInvalidArgument,
"some error",
protobuf.WithErrorDetails(&types.StringValue{Value: "abc"}),
)
}))
Spoke to @asido offline and agreed to close this issue.
Describe the bug Caller receives error
unexpected EOF
when gRPC outbound returns yarpc error with details. Doesn't happen with HTTP transport.To Reproduce Is the issue reproducible?
Steps to reproduce the behavior:
go.mod
:main.go
:Expected behavior