Repository navigation
fix(google_cloud_rpc): use the google.rpc.Code of JSON errors in Status.code - #382
Open
quaaantumdev wants to merge 1 commit into
Open
quaaantumdev wants to merge 1 commit into
quaaantumdev wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the test suite for service exceptions by refining status code assertions to match specific Google Cloud RPC error codes and adding new test cases to verify retryable behavior for specific error scenarios. I have no further feedback to provide as there were no review comments submitted.
…us.code fromHttpResponse put the HTTP status code into Status.code and dropped the google.rpc.Code that a JSON error names in its `status`. gRPC errors carry the google.rpc.Code there, and ExponentialRetry.isRetryable relies on it, so an ABORTED error received over REST was never retried. Read `status` into Status.code, and keep the HTTP status code when it is missing or unknown. Fixes googleapis#381
quaaantumdev
force-pushed
the
rpc-json-error-code
branch
from
October 26, 2026 12:47
dc2f85b to
aa8278f
Compare
Contributor
|
Can you wait until #373 for a review? It significantly change how |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #381.
For an error received as JSON,
ServiceException.fromHttpResponseput the HTTP status code intostatus.codeand dropped thegoogle.rpc.Codethat the error names instatus. gRPC errors carry thegoogle.rpc.Codethere (see_mapGrpcErroringoogle_cloud_pubsub), andExponentialRetry.isRetryablerelies on it. Over REST, anABORTEDerror (409) was therefore never retried, and callers couldn't tellABORTEDfromALREADY_EXISTS, orFAILED_PRECONDITIONfromINVALID_ARGUMENT.Changes
fromHttpResponsereads the error'sstatusintoStatus.code, for example"ABORTED"becomes 10. Whenstatusis missing or isn't agoogle.rpc.Code, the HTTP status code stays, as before.ServiceException.statusCodestill has the HTTP status code.ServiceException.statussays whatcodeholds.This changes
status.codefor JSON errors that name their code (400 becomes 3, and so on). The only other place in this repository that readsstatus.codefor a REST error isgoogle_cloud_storage'screate_bucket_test.dart. Cloud Storage's JSON API errors don't carry astatus, so that test still gets 409.Tests
valid error 400,409andothertests now expect thegoogle.rpc.Code(3, 6 and 13).ABORTEDgives 10 and is retryable, andALREADY_EXISTSis not. An error without astatus, or with an unknown one, keeps the HTTP status code.google.rpc.Codefail.dart testingenerated/google_cloud_rpc: 86 passed.dart analyze --fatal-infosanddart formatare clean.