Skip to content

fix: read a 429's limit type from the API's detail - #31

Merged
vdavez merged 1 commit into
mainfrom
fix/rate-limit-type-from-detail
Oct 19, 2026
Merged

vdavez merged 1 commit into
mainfrom
fix/rate-limit-type-from-detail

Conversation

@makegov-mark

@makegov-mark makegov-mark Bot commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

What

rateLimitInfo.limitType was always null: it only read an X-RateLimit-Type header 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's TangoRateLimitError.limit_type (1.18.2).

  • Rate limit exceeded for daily. Please try again in 16 hours, 58 minutes. → "daily" (the name is read from exceeded 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".
  • Any other detail, no detail, or a non-JSON body → null.
  • An X-RateLimit-Type header, if one is ever sent, still takes precedence.

TangoRateLimitError gains the same limitType getter plus detail (the API's message), matching python's error. The constructor takes an optional fourth argument for the header value; existing calls are unchanged.

Testing

  • New 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 both error.limitType and client.rateLimitInfo.limitType. All 12 fail on main.
  • npx vitest run, lint, typecheck, build, both conformance gates: green.

🤖 Generated with Claude Code

`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
vdavez force-pushed the fix/rate-limit-type-from-detail branch from d2b1335 to a5f49fe Compare October 19, 2026 23:02
@vdavez
vdavez marked this pull request as ready for review October 19, 2026 23:02
@vdavez
vdavez merged commit 622b57f into main Oct 19, 2026
7 checks passed
@vdavez
vdavez deleted the fix/rate-limit-type-from-detail branch October 19, 2026 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant