Skip to content
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

Beta: Fix HTTPXClient retries #1209

Merged
merged 4 commits into from
Jan 26, 2024
Merged

Conversation

richardm-stripe
Copy link
Contributor

@richardm-stripe richardm-stripe commented Jan 24, 2024

Summary

Fixes issue reported by @tsalpekaar21 in #327 (comment) where requests that should have been non-retryable were retried, and the wrong exception classes were being produced.

Details

The fix is to stop calling .raise_for_status. The .raise_for_status method causes HTTPX to produce its own exceptions for non-2xx statuses -- but this isn't actually desired. The way that the other HTTP clients in _http_client.py work is that HTTPClient._handle_request_error is responsible only for handling exceptions in cases where the HTTP request actually isn't able to complete. Completed requests with error status codes should be returned from .request so that .should_retry can run, and APIRequestor.interpret_response is responsible for converting this to an appropriate exception.

@richardm-stripe richardm-stripe marked this pull request as ready for review January 25, 2024 00:23
@richardm-stripe richardm-stripe merged commit 53648e5 into beta Jan 26, 2024
14 checks passed
@xavdid-stripe xavdid-stripe deleted the richardm-fix-async-retries branch May 10, 2024 03:28
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.

None yet

2 participants