Repository navigation
Conversation
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.
Summary
Problem / root cause
RetryTransportandAsyncRetryTransportretainedlast_responseafter subsequent network exceptions, then returned it before consideringlast_errorwhen retries were exhausted. A 503 followed by two connection failures therefore surfacedInternalServerError/503 instead of the documentedAPIConnectionError; the same issue hid final timeouts.Change
The production fix is one assignment in each catch block (
last_response = None). Existing retry statuses, delays, counts, and error conversion stay unchanged. Tests cover503 → ConnectError → ConnectError,503 → ReadTimeout → ReadTimeout, and the reverseConnectError → 503 → 502, in both sync and async clients. Generated code and exported signatures are unchanged.Testing
python -m pytest -q: 78 passed.python -m ruff check coinmarketcap tests: all checks passed.CoinMarketCap(...).cryptocurrency.quotes_latestandasync_quotes_latestmethods, real generated endpoint/client, retry transports, and typed-error wrappers. Only the innermost HTTP transport was replaced withhttpx.MockTransport; no production requests or real API key.InternalServerError/503 after three requests.APIConnectionError, timeout sequences raisedAPITimeoutError; each preserved the exact final httpx exception in.cause, with three requests.Risk / compatibility
Only mixed HTTP/transport retry exhaustion changes. A final HTTP response still wins over an earlier transport error; pure HTTP, pure network, success and retry-count behavior are covered by the existing suite. This is the Python counterpart of the independently published TypeScript fix in OpenCMC/coinmarketcap-api-typescript#1; the TS PR is not changed here.
AI assistance was used for investigation, implementation, and tests. All claimed local results were actually executed.