Skip to content

v0.5.0 — the audit, worked through

Choose a tag to compare

@jehrr jehrr released this 16 Sep 14:26
· 25 commits to main since this release
958be9f

Read this before upgrading — two exit codes change meaning.

A run that never got the page now exits 5, where it used to exit 4. A
navigation timeout, a dead proxy and a genuinely empty category were one
value to an automated caller, and those want three different responses.
Exit 4 now means only "the page was fetched and held nothing" — the one
case that says something about the catalogue.

A blocked run now exits 3 where many of them used to exit 4. Akamai's
refusal page was not recognised as a block, so every run the edge refused
reported an empty category. Nothing about your setup changed; the reports
were wrong before.

Everything else is additive.

This release works through a third-party audit taken on v0.4.2, plus what
running the code against the live site turned up along the way. All five of
the audit's P0 items are done, four of six P1, three of four P2; the ones
declined are argued in #28.

The fixes that mattered

Each of these reported a wrong answer rather than an error, which is this
codebase's worst failure mode.

Akamai's "Access Denied" page was not a block. Every request from a
datacentre address returns 318–426 bytes under HTTP 403, carrying none of the
challenge markers this parser knew — so a plainly blocked run exited 4 and
told the caller the category was empty. Reproduced live, fixed, re-run.

Two details the audit's own suggested fix would have got wrong: the same page
reaches the parser in two spellings, because Akamai entity-escapes the
punctuation on the wire while a browser serialises it back out plain — a
literal errors.edgesuite.net marker matches the browser engines and
silently misses the HTTP client. And a bare edgesuite marker would fire on
any page served from that CDN, which is worse than no marker at all.

A run that never got the page said "0 products". Now exit 5, decided in
one shared place so all three engines agree.

A parser returning nothing from a page full of product links said the same
thing.
Now stop_reason: parse_drift, and the canary fails on it by name —
that is a bug in here, not a thin category, and the two send a reader to
opposite places.

--retries 0 never fetched the page at all. The attempt loop is
range(1, retries + 1), so zero attempts meant goto() was never called: the
run parsed about:blank and exited 4. Every numeric flag is range-checked
now, before a browser launches.

New

  • --mode detail — one row per SIZE, with per-size availability and the
    real discount chain. A detail page publishes ProductGroup, not Product,
    so the listing parser finds nothing there; and it publishes the whole price
    chain as structured data, so price and original_price are facts rather
    than something to reconcile against a rendered tile.
  • --resume — every multi-page run writes a checkpoint, and a completed
    run deletes it. Not behind a flag on the first run: nobody passes
    --checkpoint on the run that is about to be killed.
  • --webhook — posts the run summary on finish, including on failure,
    which is the case worth being told about. Never fails the run, never logs
    the URL.
  • Console scripts and a GHCR image — pip install '.[playwright]' puts
    farfetch-scraper on your PATH; ghcr.io/2scraper/farfetch-scraper runs it
    without one.
  • Run metadata: run_id, timings, and a quality block giving coverage
    of every nullable column as a fraction.

Infrastructure

Ruff and mypy in CI, both narrowly configured with the reasoning in
pyproject.toml. A Docker job that builds the image, runs its entrypoint and
launches Chromium — nothing built it before, which is how this family shipped
broken images three times. An engine matrix with one venv per engine, because
the previous single environment silently resolved to versions the repo does
not support. Dependabot.

The canary is two signals: a free daily run that reports a datacentre
block as a skip rather than a failure, and a proxy-backed one that is strict.
A check that is red every morning is a check everybody learns to ignore.

Measured, not assumed

The same four products were captured on a DE and a US exit. The variant sku
is byte-identical across markets while size, colour, composition and category
are all localised — so a cross-market comparison joins on sku. Prices are
set per market rather than converted (60 EUR / 90 USD on one product;
1020 EUR / 598 USD on another), so a cross-market difference is pricing, not
arbitrage.

in_stock has never been observed false: 100 variants, 19 products, two
markets, including a whole sale section. That is recorded as an open question
rather than as verified behaviour.

Tests

374 offline checks, up from 232. pytest reports 376 results instead of 1 —
the suite's main() was one 2,650-line function and is now 28 named ones,
verified behaviour-preserving by diffing every check label before and after.