yarpc-go icon indicating copy to clipboard operation
yarpc-go copied to clipboard

Changed encoding/decoding error code to from InvalidArgument to Internal

Open biosvs opened this issue 11 months ago • 2 comments

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".

biosvs avatar Mar 15 '24 10:03 biosvs

I revisited code and tests, and revert changes for server decoding: those errors indeed indicates that client sends invalid request.

biosvs avatar Apr 30 '24 14:04 biosvs

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 85.23%. Comparing base (23c069f) to head (f0ff598).

Additional details and impacted files
@@           Coverage Diff           @@
##              dev    #2251   +/-   ##
=======================================
  Coverage   85.23%   85.23%           
=======================================
  Files         270      270           
  Lines       15555    15557    +2     
=======================================
+ Hits        13258    13260    +2     
+ Misses       1876     1875    -1     
- Partials      421      422    +1     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Apr 30 '24 14:04 codecov[bot]