Skip to content

Use canonical status code mapping from HTTP to RPC#502

Merged
jskeet merged 1 commit intogoogleapis:mainfrom
jskeet:canonical-status-codes
Nov 5, 2021
Merged

Use canonical status code mapping from HTTP to RPC#502
jskeet merged 1 commit intogoogleapis:mainfrom
jskeet:canonical-status-codes

Conversation

@jskeet
Copy link
Contributor

@jskeet jskeet commented Oct 8, 2021

This is now not consistent with the Java implementation in some cases.

This is an alternative to #490

@jskeet jskeet added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Oct 8, 2021
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Oct 8, 2021
HttpStatusCode.Conflict => StatusCode.FailedPrecondition,
// TODO: Others!
// All 2xx responses map to OK
2 => StatusCode.OK,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to this.

The Apiary libraries marks all 2xx as success, if we didn't do this here, we could get the exact same operation succeed in Apiary but "fail" in REGAPIC.

_ => StatusCode.Internal
},

// Anything else (including all 1xx and 3xx) maps to Unknown
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We handle redirects in Apiary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. Do we know if they're used? (I can't remember offhand.)
Of course, the HttpClient we use under the hood could be configured to do that automatically - I suspect we don't want to do anything different at the CallInvoker level (where this is) - but we should consider it carefully. Thanks for bringing it up.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea if they are used, tbh. I've never seen an actual redirect while debugging code, but of course, I've onle ever debugged a low percent of operations. Maybe we can at least chat to the Compute API folk and ask, or maybe to ESF?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any progress on the redirect issue? I would assume we'd want to handle it like Apiary and just follow the redirect. Ideally, that means HttpClient would do this and redirection codes would not show up here in practice....

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I haven't chased the redirect issue at all. We could definitely "ask" HttpClient to do it for us, although I don't know whether it gives up after a few redirects.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest we can merge this change without worrying about redirects for now, but I'll file an issue to make sure we remember.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for completeness, this is being tracked in #511.

@jskeet jskeet marked this pull request as ready for review November 5, 2021 07:31
@jskeet jskeet requested a review from a team November 5, 2021 07:31
@jskeet jskeet force-pushed the canonical-status-codes branch from 34d0e30 to 42d51cd Compare November 5, 2021 07:34
@jskeet jskeet removed the request for review from vchudnov-g November 5, 2021 07:39
@jskeet jskeet removed the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Nov 5, 2021
@jskeet
Copy link
Contributor Author

jskeet commented Nov 5, 2021

This has now been agreed internally, and is ready to merge if you're happy, @amanda-tarafa

Copy link
Collaborator

@amanda-tarafa amanda-tarafa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

_ => StatusCode.Internal
},

// Anything else (including all 1xx and 3xx) maps to Unknown
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for completeness, this is being tracked in #511.

@jskeet jskeet merged commit f725e2c into googleapis:main Nov 5, 2021
@jskeet jskeet deleted the canonical-status-codes branch November 5, 2021 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants