Repository navigation
fix: read a 429's limit type from the API's detail - #31
Merged
Merged
Conversation
`rateLimitInfo.limitType` only read an `X-RateLimit-Type` header the API never sends, so it was always null. On a 429 it now reads the rate's name from the detail (`Rate limit exceeded for daily. ...`) and reports `daily` or `burst`, matching tango-python's `limit_type`; a header still wins if one is sent. `TangoRateLimitError` gains `limitType` and `detail`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
vdavez
force-pushed
the
fix/rate-limit-type-from-detail
branch
from
October 19, 2026 23:02
d2b1335 to
a5f49fe
Compare
vdavez
marked this pull request as ready for review
October 19, 2026 23:02
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
rateLimitInfo.limitTypewas alwaysnull: it only read anX-RateLimit-Typeheader the Tango API never sends.On a 429 it now reads the rate's name from the API's detail and reports
"daily"or"burst", the same vocabulary and check order as tango-python'sTangoRateLimitError.limit_type(1.18.2).Rate limit exceeded for daily. Please try again in 16 hours, 58 minutes.→"daily"(the name is read fromexceeded for <name>, so "minutes" in the wait does not read as burst).Rate limit exceeded for burst. Please try again in 1 minute.→"burst".Rate limit exceeded for premium_daily. ...(a per-endpoint premium budget) →"daily".null.X-RateLimit-Typeheader, if one is ever sent, still takes precedence.TangoRateLimitErrorgains the samelimitTypegetter plusdetail(the API's message), matching python's error. The constructor takes an optional fourth argument for the header value; existing calls are unchanged.Testing
tests/unit/rateLimitType.test.ts: the detail shapes above on the error directly, and end-to-end 429s for daily, burst, unrecognized detail, non-JSON body, and header precedence, asserting botherror.limitTypeandclient.rateLimitInfo.limitType. All 12 fail onmain.npx vitest run, lint, typecheck, build, both conformance gates: green.🤖 Generated with Claude Code