Skip to content

fix(http): on_retry reports target URL on 429 under scraper_api (1.6.2) - #182

Merged
vedaant00 merged 1 commit into
mldsveda:mainfrom
vedaant00:vs-001
Sep 2, 2026
Merged

fix(http): on_retry reports target URL on 429 under scraper_api (1.6.2)#182
vedaant00 merged 1 commit into
mldsveda:mainfrom
vedaant00:vs-001

Conversation

@vedaant00

Copy link
Copy Markdown
Collaborator

Bug

The sync HTTP client's 429 (rate-limit) retry branch passed the rewritten scraper_api provider endpoint to the on_retry hook instead of the logical target URL.

# http.py, 429 branch (before)
_fire(self.config.on_retry, url, attempt, retry_after, "429 ...")  # url == api.scraperapi.com

Every other hook call in the same method already passes target_urlon_request, and the 5xx and RequestError on_retry branches — and the async client's 429 branch does too. So this was a sync/async divergence: the #171 fix ("hooks report the logical target URL, not the provider endpoint") was applied everywhere except the sync 429 path.

Impact

With scraper_api configured, a rate-limited retry fired on_retry with api.scraperapi.com instead of the site being scraped, so a user's retry dashboard/metrics misattributed the retry.

Fix

One line: pass target_url in the 429 branch, matching the siblings and the async client.

Test

Added test_on_retry_429_reports_target_url_not_scraper_api_endpoint (mirrors the existing on_request scraper_api test). Regression-proven: it fails on the old code (hook received the provider endpoint) and passes with the fix.

590 passed, ruff clean. Bumped to 1.6.2 across all four version sites + CHANGELOG.

The sync client's 429 retry branch passed the rewritten scraper_api provider
endpoint to on_retry instead of target_url, unlike every sibling hook call
(on_request, the 5xx and RequestError on_retry branches) and unlike the async
client's 429 branch. A retry dashboard/metric then attributed a rate-limited
retry to api.scraperapi.com rather than the site being scraped, violating the
mldsveda#171 contract that hooks report the logical target URL.

Regression test fails on the old code (hook saw the provider endpoint) and
passes with the one-line fix. Bump to 1.6.2.
@vedaant00
vedaant00 merged commit bec2d84 into mldsveda:main Sep 2, 2026
6 checks passed
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.

1 participant