feat(tradein-browser): additive POST /fetch-json + BrowserFetcher.fetch_json (#915 Stage 2) #1915

Merged
bot-backend merged 1 commit from feat/915-stage2-fetch-json into main 2026-06-26 09:30:36 +00:00
Collaborator

Summary

  • Add additive POST /fetch-json to the camoufox sidecar + BrowserFetcher.fetch_json() client method.
  • Lets backend run an in-page fetch() from the warm camoufox page (same-origin, real fingerprint + context cookies + per-provider proxy) and get {status, body} back.
  • Sidecar navigates to origin (anchor page, short 500ms settle vs full BROWSER_WAIT_MS), runs fetch via page.evaluate, mirrors _fetch_once lifecycle + recycle/relaunch; _do_fetch_json mirrors _do_fetch crash-retry; fetch_json_handler mirrors fetch_handler (400/503/500).
  • Client mirrors fetch's single-retry-on-HTTPError/TransportError pattern.
  • Purely additive: /fetch, _fetch_once, _do_fetch, fetch_handler, BrowserFetcher.fetch untouched. Nothing in prod calls it yet — a follow-up PR (#915 Stage 3) wires avito IMV to it, which can unblock #562 (IMV via warm browser session instead of needing the #853 proxy).

Test plan

  • Sidecar browser/test_server_fetch_json.py — 8 tests (happy path, origin navigation, explicit origin, POST passthrough, 400 missing url, 400 bad json, 503 unavailable, 500 on evaluate error + page closed).
  • Backend tests/scrapers/test_browser_fetcher.py — 5 new fetch_json tests (returns dict, full payload, defaults, one retry, raise-after-two) → 13 passed.
  • ruff check clean on all changed files.
  • Existing sidecar smoke/pacing/resource_block green — no regressions.

Refs #915

## Summary - Add additive `POST /fetch-json` to the camoufox sidecar + `BrowserFetcher.fetch_json()` client method. - Lets backend run an in-page `fetch()` from the warm camoufox page (same-origin, real fingerprint + context cookies + per-provider proxy) and get `{status, body}` back. - Sidecar navigates to `origin` (anchor page, short 500ms settle vs full `BROWSER_WAIT_MS`), runs `fetch` via `page.evaluate`, mirrors `_fetch_once` lifecycle + recycle/relaunch; `_do_fetch_json` mirrors `_do_fetch` crash-retry; `fetch_json_handler` mirrors `fetch_handler` (400/503/500). - Client mirrors `fetch`'s single-retry-on-HTTPError/TransportError pattern. - **Purely additive**: `/fetch`, `_fetch_once`, `_do_fetch`, `fetch_handler`, `BrowserFetcher.fetch` untouched. Nothing in prod calls it yet — a follow-up PR (#915 Stage 3) wires avito IMV to it, which can unblock #562 (IMV via warm browser session instead of needing the #853 proxy). ## Test plan - [x] Sidecar `browser/test_server_fetch_json.py` — 8 tests (happy path, origin navigation, explicit origin, POST passthrough, 400 missing url, 400 bad json, 503 unavailable, 500 on evaluate error + page closed). - [x] Backend `tests/scrapers/test_browser_fetcher.py` — 5 new fetch_json tests (returns dict, full payload, defaults, one retry, raise-after-two) → 13 passed. - [x] `ruff check` clean on all changed files. - [x] Existing sidecar smoke/pacing/resource_block green — no regressions. Refs #915
bot-backend added 1 commit 2026-06-26 09:26:57 +00:00
feat(tradein-browser): additive POST /fetch-json + BrowserFetcher.fetch_json (#915 Stage 2)
All checks were successful
CI / changes (pull_request) Successful in 7s
CI / backend-tests (pull_request) Has been skipped
CI / frontend-tests (pull_request) Has been skipped
CI / openapi-codegen-check (pull_request) Has been skipped
8eec6a752c
Add an in-page fetch() path so backend code can run a same-origin fetch from
inside the warm camoufox page (real fingerprint + context cookies + per-provider
proxy) and get back {status, body}. Purely additive: /fetch, _fetch_once,
_do_fetch, fetch_handler and BrowserFetcher.fetch are untouched. Nothing in the
prod flow calls it yet — a later PR wires avito IMV to it.

Sidecar: _fetch_json_once navigates to origin (anchor page, short 500ms settle
instead of full BROWSER_WAIT_MS), runs fetch via page.evaluate, mirrors the
_fetch_once page lifecycle + recycle/relaunch. _do_fetch_json mirrors _do_fetch
crash-retry. fetch_json_handler mirrors fetch_handler (400/503/500 handling).

Client: BrowserFetcher.fetch_json posts to /fetch-json with the same
single-retry-on-HTTPError/TransportError pattern as fetch.

Tests: browser/test_server_fetch_json.py (handler happy path, origin navigation,
POST payload passthrough, 400 missing url, 400 bad json, 503 unavailable, 500 on
evaluate error) and backend fetch_json client tests (payload, defaults, retry,
raise-after-two-errors).

Refs #915

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
bot-backend merged commit d479edeb3f into main 2026-06-26 09:30:36 +00:00
bot-backend deleted branch feat/915-stage2-fetch-json 2026-06-26 09:30:36 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lekss361/gendesign#1915
No description provided.