-
Notifications
You must be signed in to change notification settings - Fork 329
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
ResourceExhausted error code to HTTP 429 status code #270
Conversation
docs/spec_v7.md
Outdated
@@ -208,7 +208,7 @@ corresponding HTTP Status Code for the response. | |||
| already_exists | 409 | An attempt to create an entity failed because one already exists. | |||
| permission_denied | 403 | The caller does not have permission to execute the specified operation. It must not be used if the caller cannot be identified (use "unauthenticated" instead). | |||
| unauthenticated | 401 | The request does not have valid authentication credentials for the operation. | |||
| resource_exhausted | 403 | Some resource has been exhausted, perhaps a per-user quota, or perhaps the entire file system is out of space. | |||
| resource_exhausted | 429 | Some resource has been exhausted, perhaps a per-user quota, or perhaps the entire file system is out of space. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth mentioning rate-limiting here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about adding "exhausted or rate-limited"?
Some resource has been exhausted or rate-limited, perhaps a per-user quota, or perhaps the entire file system is out of space
protoc-gen-twirp/generator.go
Outdated
t.P(` case 429, 502, 503, 504: // Too Many Requests, Bad Gateway, Service Unavailable, Gateway Timeout`) | ||
t.P(` case 429: // Too Many Requests`) | ||
t.P(` code = `, t.pkgs["twirp"], `.ResourceExhausted`) | ||
t.P(` case 502, 503, 504: // Too Many Requests, Bad Gateway, Service Unavailable, Gateway Timeout`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove "Too Many Requests" from this line
Read more: - https://twitchtv.github.io/twirp/docs/spec_v7.html#differences-with-v5 - twitchtv/twirp#270 Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
Followup after PR: #258
After all the analysis done in #258, we decided to re-map
ResourceExhausted
to 429Too Many Requests
, instead of adding a new status code. See PR comments for more details.Backwards compatibility
This is a non-backwards compatible change, although it may only affect servers and their middleware; clients are not affected by the HTTP status code. Note that, since the update happens on the
twirp
package, the update takes effect when the package is updated.Backwards compatibility notes about changing the HTTP mapping code of resource_exhausted from
403
to429
:unavailable
(see code). New clients will handle them asresource_exhausted
.resource_exhausted
as 403, even if in the server it is mapped to 429 (the mapping is done in code).(✅ = it just works,⚠️ = corner cases may need attention, ❌ = code depending on previous behavior needs to be updated)
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.