How to send error details like as BadRequest

ghz 1years ago ⋅ 4108 views

Question

I need send rich structured error details on gRPC error.

I think it's maybe like this:

fv = BadRequest.FieldViolation(field="login", description="Name is not unique")
bad_request = BadRequest(field_violations=[fv])
context.abort(StatusCode.INVALID_ARGUMENT, bad_request.SerializeToString())

But is's wrong and send bytes in summary error text.

I use grpcio==1.17.1


Answer

I got feedback on github issue https://github.com/grpc/grpc/issues/17601

Everything works in version 1.18.0