Skip to content

fix: Retry Cloudflare origin errors (520-524) from api.paddle.com - #161

Open
cpruijsen wants to merge 1 commit into
PaddleHQ:mainfrom
cpruijsen:fix/issue-157
Open

fix: Retry Cloudflare origin errors (520-524) from api.paddle.com#161
cpruijsen wants to merge 1 commit into
PaddleHQ:mainfrom
cpruijsen:fix/issue-157

Conversation

@cpruijsen

Copy link
Copy Markdown

build_request_session in paddle_billing/Client.py retries on [429, 500, 502, 503, 504], which leaves out the Cloudflare origin
error range. api.paddle.com sits behind Cloudflare, so a 522 origin connection timeout reaches the
caller as a hard failure on the first attempt while a 502 from the same incident is retried. These are
transient by definition, which is what the retry policy exists for.

This adds 520 through 524 to status_forcelist. total and backoff_factor are untouched, so the
number of attempts and the delay between them are unchanged for the codes already listed.

The case added to tests/Functional/Client/test_Client.py asserts the mounted adapter's status_forcelist rather than the constructor
argument, so it fails if the policy stops reaching the adapter as well as if the list changes.

Fixes #157

api.paddle.com is served through Cloudflare, which returns 520-524 for
origin-side problems (522 = origin connection timeout). These were not
in the retry status_forcelist, so transient origin errors were never
retried even though retry_count defaults to 3.

Closes PaddleHQ#157
@cpruijsen
cpruijsen requested a review from a team as a code owner September 13, 2026 19:04
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.

Retry status_forcelist omits Cloudflare origin errors (520-524), so 522s from api.paddle.com are never retried

1 participant