Skip to content

Commit d12c6ee

Browse files
fix: update rate limit messages to reference num_workers and keep HTTP status code
Co-Authored-By: sophie.cui@airbyte.io <sophie.cui@airbyte.io>
1 parent cb4514e commit d12c6ee

5 files changed

Lines changed: 6 additions & 6 deletions

File tree

airbyte_cdk/sources/streams/http/error_handlers/default_error_mapping.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
429: ErrorResolution(
6262
response_action=ResponseAction.RATE_LIMITED,
6363
failure_type=FailureType.transient_error,
64-
error_message="Rate limit exceeded. Try decreasing concurrency or the number of workers to stay within API rate limits.",
64+
error_message="Rate limit exceeded (HTTP status code 429). Try decreasing the number of workers to stay within API rate limits.",
6565
),
6666
500: ErrorResolution(
6767
response_action=ResponseAction.RETRY,

airbyte_cdk/sources/streams/http/http_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ def _send_with_retry(
297297
self._logger.error("Rate limit retries exhausted.", exc_info=True)
298298
raise AirbyteTracedException(
299299
internal_message=f"Rate limit retries exhausted. Exception: {e}",
300-
message="Rate limit exceeded and retries exhausted. Try decreasing concurrency or the number of workers to stay within API rate limits.",
300+
message="Rate limit exceeded and retries exhausted. Try decreasing the number of workers to stay within API rate limits.",
301301
failure_type=e.failure_type or FailureType.transient_error,
302302
exception=e,
303303
stream_descriptor=StreamDescriptor(name=self._name),

airbyte_cdk/sources/streams/http/rate_limiting.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def log_retry_attempt(details: Mapping[str, Any]) -> None:
147147
)
148148
logger.info(
149149
f"Rate limit hit after {details['tries']} tries. Waiting {details['wait']} seconds then retrying. "
150-
f"Try decreasing concurrency or the number of workers to stay within API rate limits."
150+
f"Try decreasing the number of workers to stay within API rate limits."
151151
)
152152

153153
return backoff.on_exception( # type: ignore # Decorator function returns a function with a different signature than the input function, so mypy can't infer the type of the returned function

unit_tests/sources/declarative/requesters/error_handlers/test_http_response_filter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
ErrorResolution(
6060
response_action=ResponseAction.RETRY,
6161
failure_type=FailureType.transient_error,
62-
error_message="Rate limit exceeded. Try decreasing concurrency or the number of workers to stay within API rate limits.",
62+
error_message="Rate limit exceeded (HTTP status code 429). Try decreasing the number of workers to stay within API rate limits.",
6363
),
6464
id="test_http_code_matches_retry_action",
6565
),

unit_tests/sources/streams/http/test_http.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def get_error_handler(self) -> Optional[ErrorHandler]:
223223

224224
with pytest.raises(
225225
AirbyteTracedException,
226-
match="Rate limit exceeded. Try decreasing concurrency or the number of workers to stay within API rate limits.",
226+
match="Rate limit exceeded \\(HTTP status code 429\\). Try decreasing the number of workers to stay within API rate limits.",
227227
):
228228
list(stream.read_records(SyncMode.full_refresh))
229229
if retries <= 0:
@@ -317,7 +317,7 @@ def test_raise_on_http_errors_off_429(mocker):
317317
mocker.patch.object(requests.Session, "send", return_value=req)
318318
with pytest.raises(
319319
AirbyteTracedException,
320-
match="Rate limit exceeded. Try decreasing concurrency or the number of workers to stay within API rate limits.",
320+
match="Rate limit exceeded \\(HTTP status code 429\\). Try decreasing the number of workers to stay within API rate limits.",
321321
):
322322
stream.exit_on_rate_limit = True
323323
list(stream.read_records(SyncMode.full_refresh))

0 commit comments

Comments
 (0)