-
Notifications
You must be signed in to change notification settings - Fork 211
Description
Currently, clients using the fc-control client are able to receive grpc error codes in error objects returned by API calls, but those are very generic error types that don't communicate more specific information back to the caller. More specific information is at minimum extremely useful for integration testing (allows you to assert the correct failure occurred), but is also potentially valuable for real users who want to know what specifically went wrong for specific error-handling.
I spent a day trying various ways of implementing this as part of the drive mount support (where we want to assert on specific errors occuring in integ tests), but all the ways I tried either didn't work or became too large an effort:
- I tried updating APIs to return an actual response object (instead of
Empty
) that contained a field with an error type enum. The enum field would be set to a specific error code whenever a service returned a non-nil error. This was a nice interface for both client and server, but didn't work in practice because ttrpc (and possible grpc too, have not checked) will ignore any response object returned by a service if the service also returns a non-nil error (setting the response to nil). This makes the interface much uglier and difficult to manage correctly for both services and clients. - grpc status objects contain a
Details
field, which seems to be potentially useful for returning typed details of what error occurred. However, the interface is hard to use as it requires the details be protobuf messages (not just strings) and adding details to a status object itself can return an error (so we can get an error trying to generate an error object)... This may be viable but might be a large effort. - We can include specific error codes in the grpc status object Message field, but this leaves clients to check error types via string matching (which is very fragile). We could also consider structuring of messages (with associate serialization and deserialization), though that's a large effort and feels a bit odd because we'd be doing ser/der within our already ser/der'd protobuf messages.
Right now, I think figuring out how to use the Details field of the grpc status object may be the most promising, but this needs more investigation.