Open biosvs opened 3 months ago
I revisited code and tests, and revert changes for server decoding: those errors indeed indicates that client sends invalid request.
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 85.23%. Comparing base (
23c069f
) to head (f0ff598
).
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Functions newClientEncodingError and newServerEncodingError are called only when encoding/decoding attempt is failed, which means that either structure can't be transformed into bytes, or bytes can't be read into structure.
Currently such errors lead to CodeInvalidArgument (3) return code.
As yarpc error codes relates to grpc error codes, we may assume that meaning is also close (if not the same). In grpc-go source code the same encoding/decoding errors lead to CodeInternal code (1, 2), and so the same code should be returned in yarpc.
This PR changes CodeInvalidArgument (3) to CodeInternal(13) for most such cases.
Except for server decoding errors. If server can't decode body or header of the request, it indeed indicates that client tries to send something unexpected. (This is a change from previous review.)
It's an API change, but in a worst case we expect to have more visibility on problems that were hidden by "client errors".