Repository navigation
fix: emit specific error message when API rate limit retries are exhausted - #1004
Conversation
…usted When HTTP 429 retries are exhausted, replace the generic 'Exhausted available request attempts' message with 'API rate limit exceeded.' and ensure the failure type is transient_error. This gives users a clear signal that the failure is due to rate limiting rather than an opaque internal error. Co-Authored-By: bot_apk <apk@cognition.ai>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
👋 Greetings, Airbyte Team Member!Here are some helpful tips and reminders for your convenience. 💡 Show Tips and TricksTesting This CDK VersionYou can test this version of the CDK using the following: # Run the CLI from this branch:
uvx 'git+https://github.com/airbytehq/airbyte-python-cdk.git@devin/1777352642-fix-rate-limit-error-message#egg=airbyte-python-cdk[dev]' --help
# Update a connector to use the CDK from this branch ref:
cd airbyte-integrations/connectors/source-example
poe use-cdk-branch devin/1777352642-fix-rate-limit-error-messagePR Slash CommandsAirbyte Maintainers can execute the following slash commands on your PR:
|
Co-Authored-By: bot_apk <apk@cognition.ai>
Co-Authored-By: bot_apk <apk@cognition.ai>
There was a problem hiding this comment.
Pull request overview
This PR improves user-facing error reporting when HTTP 429 (rate limiting) retries are exhausted in the CDK HttpClient, emitting a targeted AirbyteTracedException so the root cause isn’t obscured by generic platform errors.
Changes:
- Detects retry exhaustion caused by HTTP 429 in
HttpClient._send_with_retryand raises anAirbyteTracedExceptionwith messageAPI rate limit exceeded.andFailureType.transient_error. - Keeps existing behavior for non-429 retry exhaustion unchanged.
- Updates unit tests to assert the new user-facing message for 429 exhaustion scenarios.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
airbyte_cdk/sources/streams/http/http_client.py |
Adds 429 exhaustion detection and throws a more specific traced exception with transient failure type. |
unit_tests/sources/streams/http/test_http.py |
Updates expectations to match the new rate-limit error message. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| with pytest.raises( | ||
| AirbyteTracedException, match="Exception: HTTP Status Code: 429. Error: Too many requests." | ||
| AirbyteTracedException, | ||
| match="API rate limit exceeded.", | ||
| ): |
There was a problem hiding this comment.
pytest.raises(..., match=...) uses a regex. The trailing . in "API rate limit exceeded." will match any character, so this assertion could pass even if the message changes slightly. Consider escaping the dot (e.g., matching a literal period) or using re.escape(...) to ensure the test asserts the exact message.
| with pytest.raises( | ||
| AirbyteTracedException, | ||
| match="Exhausted available request attempts. Please see logs for more details. Exception: HTTP Status Code: 429. Error: Too many requests.", | ||
| match="API rate limit exceeded.", | ||
| ): |
There was a problem hiding this comment.
pytest.raises(..., match=...) treats match as a regex; the . at the end of "API rate limit exceeded." matches any character. Escaping the period (or using re.escape) would make this assertion stricter and avoid accidental false positives.
Summary
When HTTP 429 retries are exhausted, the CDK currently produces a generic
Exhausted available request attempts. Please see logs for more details. Exception: HTTP Status Code: 429. Error: Too many requests.message — which the platform often overwrites withSomething went wrong within the source connector. This gives users no indication that rate limiting is the root cause.This PR detects 429 retry exhaustion in
HttpClient._send_with_retryand raises a targetedAirbyteTracedExceptionwith:API rate limit exceeded.(follows error message guidelines)transient_error(rate limiting is transient, not a system error)Non-rate-limit retry exhaustion is unchanged.
Resolves https://github.com/airbytehq/airbyte-internal-issues/issues/16258
Related to https://github.com/airbytehq/oncall/issues/12105
Review & Testing Checklist for Human
http_client.py:303-306correctly identifies 429 responses viae.response.status_code == requests.codes.too_many_requestsAPI rate limit exceeded.meets the error message guidelines and is a net improvement over the old generic messagetransient_errorFailureType is correct for rate-limit exhaustion (rate limits are transient, not config or system errors)Notes
exit_on_rate_limit=True(DefaultBackoffException) andexit_on_rate_limit=False(RateLimitBackoffException) pathsHTTPAPIBudgetrate limitingLink to Devin session: https://app.devin.ai/sessions/9f9470b028bc44949d86e9339f195908