fix(avito): reconnect-retry on detail 403/firewall under backconnect proxy #1768
No reviewers
Labels
No labels
admin
analytics
auth
automation
bug
business
chore
ci
compliance
data
data-moat
docs
duplicate
dx
enhancement
Fable 5 ревью
feedback/max
generative
GG-форсайт
needs-discussion
needs-human
observability
pause-bots
performance
priority/p0
priority/p1
priority/p2
priority/p3
scope/backend
scope/db
scope/devops
scope/frontend
scope/qa
scrapers
security
site-finder
stage/1
stage/2
status/blocked
status/done
status/needs-analysis
status/needs-fix
status/qa
status/ready
status/review
status/wip
tech-debt
tradein
ux
week ревью 1
wontfix
вторичка
ИРД
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lekss361/gendesign#1768
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "fix/avito-detail-403-reconnect-retry"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem — avito detail coverage stuck at 14% of active
fetch_detailraised on the first 403/429 with no retry (avito_detail.py), so the nightlyavito_detail_backfillaborts on a few blocks — run 191 enriched only 48 listings then zombied. Result: only 669/4776 active avito listings (14%) have detail; 86% never enriched.The detail fetcher egresses through
settings.scraper_proxy_url= the live backconnect proxy (same as SERP — confirmed via_avito_proxies()), which rotates exit IP per new connection. So a 403 just means the current exit IP is flagged — exactly the situation the merged SERP fix (#1764/#1765) handles by rebuilding the session. The detail path simply never got that treatment.(Diagnostic note:
cadastral_number=0and Domoteka fields at 25–33% are expected, not bugs — avito doesn't publish cadastral, and the Rosreestr widget is optional. This PR is purely about throughput/coverage, not those fields.)Fix — mirror #1765 in the detail fetcher
_AVITO_DETAIL_403_MAX_RETRIES=5,_AVITO_DETAIL_403_BACKOFF_SEC=2.0,_AVITO_DETAIL_429_MAX_RETRIES=4,_AVITO_DETAIL_429_BACKOFF_SEC=1.5._build_detail_session()helper (extracted from the own-session branch).AvitoBlockedError.Session ownership (the careful bit)
The caller-provided
cffi_session(shared from the backfill loop / sweep) is never closed or rebuilt — retries always use an ephemeralretry_session.finallyclosessessiononly whenown_session, and always closes anyretry_sessioncreated (guarded against double-close).Tests
New
tests/scrapers/test_avito_detail_403_reconnect.py(6 tests): caller-session 403→403→200 (asserts caller session NOT closed), firewall(200)→200, 403 exhausted→raise, 429 short-retry→200 (same session reused), no-proxy single-403→raise, own-session 403→200 (both sessions closed).tests/scrapers/ -k "avito and detail": 10 passed; fulltests/scrapers/: 136 passed. Ruff clean.Next: after merge+deploy, re-trigger the detail backfill and measure enriched/attempted vs run 124's 88% baseline; active coverage should climb past 14%.