Repository navigation
fix: read a 429's limit type from the API's detail - #13
Merged
Merged
Conversation
`Error::RateLimit`'s `limit_type` was read only from an `X-RateLimit-Type` header the Tango API does not send, so it was always `None`. It is now `"daily"` or `"burst"`, read from the rate named in the 429 body's `detail` (`Rate limit exceeded for daily. ...`), matching tango-python 1.18.2; a header still wins when present. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
What
Error::RateLimit'slimit_typenow reports which limit a 429 hit,"daily"or"burst", instead of always beingNone.Why
The SDK read the limit type only from an
X-RateLimit-Typeheader, which the Tango API does not send.The API names the tripped rate in the 429 body's
detailinstead:Rate limit exceeded for daily. Please try again in 16 hours, 58 minutes.This matches tango-python 1.18.2, which reads the same field the same way.
How
exceeded foris read, never the wait text, so a daily lockout whose wait mentions minutes is not reported as burst.daily, or the wordday), then burst (burstorminute); anything else isNone.premium_daily) reports as"daily".X-RateLimit-Typeheader still takes precedence, so a future header wins.Error::RateLimit(the enum is#[non_exhaustive]; no variant or field is added).RateLimitInfois untouched.Testing
premium_daily,Too many requests., an empty detail, a non-stringdetail, a non-JSON body, an empty body, header precedence, and an empty header falling back to the detail.Some("daily").cargo fmt --checkandcargo clippy --workspace --all-features -- -D warningson 1.80 and stable;cargo test --workspacewith--all-featuresand--no-default-featureson stable and 1.80.🤖 Generated with Claude Code