-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: (HttpClient) rate limit fix unlimited tries #171
Conversation
[skip ci] Signed-off-by: Artem Inzhyyants <[email protected]>
Signed-off-by: Artem Inzhyyants <[email protected]>
Signed-off-by: Artem Inzhyyants <[email protected]>
Signed-off-by: Artem Inzhyyants <[email protected]>
📝 WalkthroughWalkthroughThe changes involve modifications to the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
unit_tests/sources/streams/http/test_http_client.py (1)
694-694
: Great test improvements!The type hints and test cases properly verify the rate limit behavior. One minor suggestion: would you consider adding a docstring to explain the test scenarios? Something like:
def test_backoff_strategy_endless( exit_on_rate_limit: bool, expected_call_count: int, expected_error: Exception ) -> None: """Test rate limit backoff behavior with different exit_on_rate_limit values. Args: exit_on_rate_limit: If True, stops retrying after max attempts. If False, continues indefinitely. expected_call_count: Expected number of retry attempts. expected_error: Expected exception type (DefaultBackoffException or RateLimitBackoffException). """wdyt? 🤔
Also applies to: 697-699
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
airbyte_cdk/sources/streams/http/http_client.py
(2 hunks)unit_tests/sources/streams/http/test_http_client.py
(2 hunks)
🔇 Additional comments (3)
airbyte_cdk/sources/streams/http/http_client.py (2)
475-477
: Clean implementation of RateLimitBackoffException!
The exception properly captures all necessary context (request, response, error_message) for debugging rate limit issues.
265-265
: LGTM! The rate limit handler now respects max_tries parameter.
The fix correctly addresses the unlimited retries issue by passing the max_tries parameter to the rate limit handler.
Let's verify the rate limit handler's behavior:
✅ Verification successful
The initial results show the function is only used in the HTTP client, but let's verify its implementation and test coverage to ensure it properly handles the max_tries parameter.
Let's try a different approach to examine the implementation and test coverage. The previous pattern matching might have been too strict, so we'll look at the actual file content.
The implementation shows that rate_limit_default_backoff_handler
accepts and forwards kwargs (including max_tries) to the backoff decorator. Let's verify the test coverage and exception handling to ensure it works as expected.
I see the RateLimitBackoffException is used in the HTTP client, but let's check the test file to verify how the max_tries parameter is validated in the rate limiting context.
LGTM! The rate limit handler correctly handles max_tries parameter
After reviewing the implementation and tests, I can confirm that:
- The
rate_limit_default_backoff_handler
properly accepts and forwards kwargs (including max_tries) to the backoff decorator - The HTTP client tests verify that rate limiting respects the retry limits
- The implementation correctly raises RateLimitBackoffException after exhausting retries
- Test
test_backoff_strategy_endless
specifically verifies the rate limit behavior with max_tries=6 (default) - The rate limit handler is consistently used across the codebase
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check if rate_limit_default_backoff_handler is used consistently across the codebase
# Search for other instances of rate_limit_default_backoff_handler to ensure consistent usage
rg "rate_limit_default_backoff_handler" -A 3
Length of output: 1169
Script:
#!/bin/bash
# Let's check the implementation of rate_limit_default_backoff_handler to verify max_tries handling
ast-grep --pattern 'def rate_limit_default_backoff_handler($$$)'
# Also check for any tests that verify this behavior
rg "test.*rate_limit.*backoff" -l
Length of output: 102
Script:
#!/bin/bash
# Let's check the content of the rate limiting module
cat airbyte_cdk/sources/streams/http/rate_limiting.py
# And look for any test files related to rate limiting
fd test.*rate.*limit
Length of output: 6470
Script:
#!/bin/bash
# Let's check the test file to verify rate limit backoff behavior
cat unit_tests/utils/test_rate_limiting.py
# Also check for any usage of RateLimitBackoffException to understand the error handling
rg "RateLimitBackoffException" -A 2
Length of output: 2711
Script:
#!/bin/bash
# Let's check the HTTP client test file to see how rate limiting is tested
cat unit_tests/sources/streams/http/test_http_client.py
Length of output: 25936
unit_tests/sources/streams/http/test_http_client.py (1)
23-23
: LGTM! Clean import addition.
The RateLimitBackoffException import is properly placed with other related exceptions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
What
Resolving Source Amazon Seller Partner CDK migration
bugfix for:
RateLimitBackoffException
(boolean comparison returnexc
since all nonok
responses areFalse
Summary by CodeRabbit
New Features
RateLimitBackoffException
for clearer error messaging.Bug Fixes
Tests