fix: do not retry a 429 when API credits are exhausted - #15
Merged
Conversation
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Sync with python-client 0.3.1 (PR #28). A 429 covers three cases — a burst limit, a rate limit, and exhausted API credits — and the client retried all three. Waiting out the backoff cannot conjure more credits, so an exhausted quota burned the full retry budget (~62s on the default five attempts) before surfacing an error that was never going to clear. The 429 branch now reads `results.code` and fails immediately when it means exhausted credits. Transient 429s retry exactly as before. ApiLimitExceeded is the documented code (see the ErrorCode enum in https://newsdata.io/openapi.json, whose 429 response is described as "Too many requests in a short period, rate limit exceeded, or API credits exhausted"). ApiKeyLimitExceeded is accepted too: it is absent from the spec, but python-client sends it and the spec has proven incomplete before, so dropping it would silently miss key-scoped quotas.
arjunjain
force-pushed
the
fix/quota-exhausted-no-retry
branch
from
September 3, 2026 01:26
368c09a to
8e9afda
Compare
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.
Syncs this client with python-client 0.3.1 (PR #28), which fixed the 429 retry logic when an API key's credits are exhausted.
The problem
A
429covers three different conditions. The OpenAPI spec's shared 429 response says so outright:This client retried all three. Waiting out the backoff cannot conjure more credits, so an exhausted quota burned the full retry budget — about 62s across the default five attempts — before surfacing an error that was never going to clear.
The fix
The 429 branch now reads
results.codeand fails immediately when it means exhausted credits. Transient 429s retry exactly as before.ApiLimitExceededApiKeyLimitExceededRateLimitExceededTooManyRequestsOn
ApiKeyLimitExceededIt is not in the spec's
ErrorCodeenum — onlyApiLimitExceededis. It is kept anyway because python-client sends it, and this spec has proven incomplete before (it omitsnews_typeonwebsocket/registerentirely, and lagged on thesymbol→market_idrename). Dropping it would silently miss key-scoped quota exhaustion.Tests
Two per client: a quota code makes exactly one request, and a non-quota 429 still retries — so this cannot regress into a blanket no-retry.