This repository was archived by the owner on Sep 26, 2023. It is now read-only.
fix: update exception mapping on HTTP error responses#1570
Merged
chanseokoh merged 5 commits intomainfrom Dec 2, 2021
Merged
Conversation
Interprets HTTP error reponse codes as defined by the canonical error code mapping. Not marking as breaking changes as it affects only httpjson that is not GA-ed.
Contributor
Author
|
@meltsufin @vam-google ready for review. Check out the PR description for details. |
meltsufin
approved these changes
Nov 23, 2021
gax-httpjson/src/test/java/com/google/api/gax/httpjson/HttpJsonStatusCodeTest.java
Outdated
Show resolved
Hide resolved
vam-google
approved these changes
Nov 29, 2021
Contributor
vam-google
left a comment
There was a problem hiding this comment.
LGTM, but we need to test it with java-compute properly before GA, as it may affect its behavior and retries in particular.
| throw new IllegalArgumentException("Unrecognized http status code: " + httpStatus); | ||
| } | ||
| } | ||
| return Code.UNKNOWN; |
Contributor
There was a problem hiding this comment.
Is mapping 300s to unknown intentional and canonical behavior here?
Contributor
Author
There was a problem hiding this comment.
Yes, All 3xx's are mapped to UNKNOWN according to go/http-canonical-mapping.
Contributor
Author
|
As mentioned in b/205195666, I have conducted multiple tests for this change, whose results seem all good. @vam-google merging this now, but if you want me to do some other tests, just let me know. |
gcf-merge-on-green bot
pushed a commit
that referenced
this pull request
Dec 2, 2021
🤖 I have created a release \*beep\* \*boop\* --- ### [2.7.1](https://www.github.com/googleapis/gax-java/compare/v2.7.0...v2.7.1) (2021-12-02) ### Bug Fixes * fix gRPC code conversion ([#1555](https://www.github.com/googleapis/gax-java/issues/1555)) ([09b99d5](https://www.github.com/googleapis/gax-java/commit/09b99d591497b44c3c25b1a54abb0f1cb69d7376)) * pass error message when creating ApiException ([#1556](https://www.github.com/googleapis/gax-java/issues/1556)) ([918ae41](https://www.github.com/googleapis/gax-java/commit/918ae419f84ad5721638ca10eca992333e9f7c3d)) * revert generics syntax change in MockHttpService test utility ([#1574](https://www.github.com/googleapis/gax-java/issues/1574)) ([b629488](https://www.github.com/googleapis/gax-java/commit/b629488ffc7d68158158d9197695158f97229c7b)) * update exception mapping on HTTP error responses ([#1570](https://www.github.com/googleapis/gax-java/issues/1570)) ([8a170d1](https://www.github.com/googleapis/gax-java/commit/8a170d19b42e9b13d4c69dcfbe531d4d4ca69c90)) ### Dependencies * update grpc to 1.42.1 ([#1559](https://www.github.com/googleapis/gax-java/issues/1559)) ([92b7632](https://www.github.com/googleapis/gax-java/commit/92b76325d54604c98c798c489b3a963fdf21a75c)) * upgrade protobuf to 3.19.1 ([#1571](https://www.github.com/googleapis/gax-java/issues/1571)) ([7b354e7](https://www.github.com/googleapis/gax-java/commit/7b354e73b8ce49008bed51076afb255ca5dc68e4)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The HTTP-to-Canonical code conversion (
HttpJsonStatusCode.httpStatusToStatusCode()) is used only for error situations where a server returns a non-2xx HTTP status code. gax-java surfaces errors in terms ofApiExceptions, which are modeled precisely following the canonical status codes (go/canonical-codes). (That is, there's a one-to-one correspondence between the canonical error codes and the Java exceptions.) That's why and the only reason we need to interpret HTTP codes as canonical codes.The previous implementation wasn't following the standardized mapping (go/http-canonical-mapping). Now we are trying to make this consistent across all languages. Therefore, this does introduce a breaking change in terms of which HTTP server response code is surfaced as which Java exception.
However, for the conventional commit message and the PR title, I'm not marking as a breaking change, as gax-httpjson hasn't GA'ed.
b/205195666
Appendix
The locations where the HTTP-to-canonical conversion takes place:
HttpJsonExceptionCallable.onFailure(): HTTP error status is interpreted as canonical error status (via exception).HttpJsonOperationSnapshot.Builder.setError(): the builder takes an HTTP code. Note there's no usage ofsetError()within gax-java. It is supposed to take HTTP code, but for some legacy reason, it treats 0 as a special case to indicate success (which is not ideal).