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

HTTP exception mapping missing ALREADY_EXISTS #2620

Open
kolea2 opened this issue Apr 4, 2024 · 5 comments
Open

HTTP exception mapping missing ALREADY_EXISTS #2620

kolea2 opened this issue Apr 4, 2024 · 5 comments
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@kolea2
Copy link
Contributor

kolea2 commented Apr 4, 2024

On HTTP exceptions, exceptions that should be ALREADY_EXISTS (409) are being propagated as ABORTED (also 409).

This code change seems to have removed the behavior: cdf4614#diff-ecd504e117f5a7eedb2f2df5df3a32ac6bc85e21c870ff702c0de2771b33a21eL125-L129

image

Is there a reason for this, or can we restore this logic?

Thanks!

@kolea2 kolea2 added the type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. label Apr 4, 2024
@suztomo
Copy link
Member

suztomo commented Apr 11, 2024

The pull request associated to the commit points to a wrong URL due to repository relocation. The correct pull request is googleapis/gax-java#1570

gax-java surfaces errors in terms of ApiExceptions, 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.)

go/canonical-codes does have ALREADY_EXISTS.

@chanseokoh Do you happen to remember why the condition for ALREADY_EXISTS was removed at that time?

@suztomo suztomo added the priority: p2 Moderately-important priority. Fix may not be included in next release. label Apr 11, 2024
@chanseokoh
Copy link
Contributor

ALREADY_EXISTS (409) are being propagated

409, which is an HTTP response status code, is CONFLICT, not ALREADY_EXISTS: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409

as ABORTED (also 409).

OTOH, ABORTED is a canonical error code, not an HTTP status code. And its value is 10, not 409.

The conversion mapping between the two code spaces is defined by go/http-canonical-mapping.

However, I just realized that the doc also says

The guiding principle is that a mapping is only defined when it is unequivocally correct. In particular, there may be some circumstances where there is a more appropriate HTTP status code for a canonical code (because HTTP codes are finer-grained), and when you know that is the case it is fine to substitute an alternative code.

, so maybe it's fine to restore the previous best-effort logic to identify ALREADY_EXISTS?

@chanseokoh
Copy link
Contributor

But I don't have the expertise on this subject. At least I think the current behavior isn't wrong based on go/http-canonical-mapping.

@suztomo
Copy link
Member

suztomo commented Apr 23, 2024

Memo: "It was compatibility testing errors for gRPC and HTTP for Datastore. gRPC throws ALREADY_EXISTS, but I ran into this issue for HTTP (reGAPIC)." (Kristen)

@suztomo suztomo added priority: p3 Desirable enhancement or fix. May not be included in next release. and removed priority: p2 Moderately-important priority. Fix may not be included in next release. labels Apr 23, 2024
@kolea2
Copy link
Contributor Author

kolea2 commented Apr 23, 2024

Discussed offline with @suztomo, I will try to pick this up to fix in future cycles (but if someone needs this sooner, feel free to start work on it 😄 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

3 participants