Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix gRPC code conversion #1555

merged 3 commits into from Nov 18, 2021

fix: fix gRPC code conversion #1555

merged 3 commits into from Nov 18, 2021


Copy link

@chanseokoh chanseokoh commented Nov 12, 2021

  • HttpJsonExceptionCallable: HTTP response code is first converted to Code (the actual HTTP code value is lost here during conversion), and later, StatusCode (which is designed to hold an HTTP response code value) is constructed from the converted Code. The mapping back to HTTP codes is by the canned default values of Code, so precision is lost due to the double conversion.

  • HttpJsonStatusCode.of( rpcCode) is passing rpcCode.getNumber() (which returns integer values 0, 1, 2, 3 ...) as an argument that accepts the HTTP response code, which is wrong. As the best effort, give the canned default HTTP codes.

Unrelated, I don't think there is a reason in our codebase to hold and carry an HTTP response code inside HttpJsonStatusCode, which is not going to be used anywhere and only there to cause this sort of maintenance trouble.

@chanseokoh chanseokoh requested review from meltsufin and vam-google Nov 12, 2021
@chanseokoh chanseokoh requested review from as code owners Nov 12, 2021
@google-cla google-cla bot added the cla: yes label Nov 12, 2021
@chanseokoh chanseokoh merged commit 09b99d5 into main Nov 18, 2021
6 checks passed
@chanseokoh chanseokoh deleted the fix-HttpJsonStatusCode branch Nov 18, 2021
gcf-merge-on-green bot pushed a commit that referenced this issue Dec 2, 2021
🤖 I have created a release \*beep\* \*boop\*
### [2.7.1]( (2021-12-02)

### Bug Fixes

* fix gRPC code conversion ([#1555]( ([09b99d5](
* pass error message when creating ApiException ([#1556]( ([918ae41](
* revert generics syntax change in MockHttpService test utility ([#1574]( ([b629488](
* update exception mapping on HTTP error responses ([#1570]( ([8a170d1](

### Dependencies

* update grpc to 1.42.1 ([#1559]( ([92b7632](
* upgrade protobuf to 3.19.1 ([#1571]( ([7b354e7](

This PR was generated with [Release Please]( See [documentation](
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
cla: yes
None yet

Successfully merging this pull request may close these issues.

None yet

2 participants