Skip to content

fix(extract): stop reporting a per-domain rejection limit as a used-up allowance - #84

Merged
jonathan-zenrows merged 1 commit into
mainfrom
fix/extract-prepare-rejection-limit-not-allowance
Nov 23, 2026
Merged

jonathan-zenrows merged 1 commit into
mainfrom
fix/extract-prepare-rejection-limit-not-allowance

Conversation

@jonathan-zenrows

Copy link
Copy Markdown
Contributor

What changes for a caller

zenrows extract prepare now reports the prepare endpoint's 429 domain_rejection_limit as its own error, EXTRACT_PREPARE_DOMAIN_REJECTION_LIMIT. It means verification rejected this domain's preparations as many times as the monthly per-domain limit allows. The error carries the server's detail as likely_cause. Its next_action names four facts:

  • Do not retry this domain this month; new attempts reopen at the start of next month (UTC).
  • This submission used no allowance slot.
  • The account can still prepare other domains.
  • Meanwhile, extract this domain with --css.

A 429 with a code the CLI does not know is no longer reported as a used-up allowance. It is EXTRACT_PREPARE_FAILED with the server's detail in the message and "do not retry in a loop" as the next step.

out_of_allowance keeps its error, EXTRACT_PREPARE_OUT_OF_ALLOWANCE, word for word.

The project readme and both extract skills now list the new code and say that a preparation rejected by verification gives its slot back.

Why

Before this change every 429 from the prepare endpoint became EXTRACT_PREPARE_OUT_OF_ALLOWANCE. A caller who hit the per-domain rejection limit read that the allowance was gone. That was false. The submission spent nothing, and the account could still prepare other domains.

Tests

  • npm run typecheck: clean.
  • npm test: 517 of 517 pass.
  • New tests in tests/extract-prepare.test.ts:
    • domain_rejection_limit with limit 3.
    • domain_rejection_limit with limit 0.
    • An unknown 429 code reports the server's detail.
  • The existing table test still checks that out_of_allowance maps to EXTRACT_PREPARE_OUT_OF_ALLOWANCE with "10 of 10 used".

Live proof

The built CLI (node dist/bin/zenrows.js) was run against a local HTTP stub on ZENROWS_API_BASE=http://127.0.0.1:18765/v1. The stub answers POST /v1/extract/prepared-domains with a 429 problem body. The key was a dummy value.

Stub answers 429 domain_rejection_limit (the server's exact body, rejected: 3, limit: 3):

✗ [EXTRACT_PREPARE_DOMAIN_REJECTION_LIMIT] example.com has reached the monthly limit of preparations rejected by verification (3 rejected this month, limit 3 per domain).
  cause: (domain_rejection_limit) example.com had 3 rejected preparation attempts this month (failed verification); the limit is 3 per domain per month. This submission was not accepted and not counted against your allowance. New attempts for this domain reopen at the start of next month (UTC).
  next:  Do not retry this domain this month; new attempts reopen at the start of next month (UTC). This submission used no allowance slot, and other domains can still be prepared. Meanwhile extract this domain with --css and explicit selectors.
  $ zenrows extract <url> --css '{"title":"h1"}'
exit=1

With --json:

{
  "ok": false,
  "error": {
    "code": "EXTRACT_PREPARE_DOMAIN_REJECTION_LIMIT",
    "message": "example.com has reached the monthly limit of preparations rejected by verification (3 rejected this month, limit 3 per domain).",
    "likely_cause": "(domain_rejection_limit) example.com had 3 rejected preparation attempts this month (failed verification); the limit is 3 per domain per month. This submission was not accepted and not counted against your allowance. New attempts for this domain reopen at the start of next month (UTC).",
    "next_action": "Do not retry this domain this month; new attempts reopen at the start of next month (UTC). This submission used no allowance slot, and other domains can still be prepared. Meanwhile extract this domain with --css and explicit selectors.",
    "suggested_commands": [
      "zenrows extract <url> --css '{\"title\":\"h1\"}'"
    ],
    "server_code": "domain_rejection_limit"
  }
}
exit=1

Negative case: the same stub answers 429 out_of_allowance (used: 10, limit: 10), and the CLI prints the same allowance error as before:

✗ [EXTRACT_PREPARE_OUT_OF_ALLOWANCE] This account has used its monthly allowance of new domains to prepare (10 of 10 used).
  cause: (out_of_allowance) This account has prepared 10 of 10 new domains this month.
  next:  Do not retry this month. Meanwhile extract this domain with --css and explicit selectors.
  $ zenrows extract <url> --css '{"title":"h1"}'
exit=1

The stub logged exactly one POST /v1/extract/prepared-domains per run, so the CLI does not retry either 429.

…p allowance

A 429 domain_rejection_limit from the prepare endpoint means this domain's
preparations failed verification as often as the monthly per-domain limit
allows. The CLI mapped every 429 to EXTRACT_PREPARE_OUT_OF_ALLOWANCE, which
told callers their allowance was gone when nothing was spent and other
domains could still be prepared.

It is now EXTRACT_PREPARE_DOMAIN_REJECTION_LIMIT with the server's detail and
the next step. A 429 with a code the CLI does not know reports the server's
detail instead of claiming the allowance. The docs also say a preparation
rejected by verification gives its slot back.
@jonathan-zenrows
jonathan-zenrows marked this pull request as ready for review November 23, 2026 08:38

@gonzalo-zenrows gonzalo-zenrows left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I verified that domain_rejection_limit tells the caller to stop retrying only the affected domain, including when the server returns a limit of 0. An explicit out_of_allowance keeps its existing error, and the CLI sends the prepare request once.

@jonathan-zenrows
jonathan-zenrows merged commit d69c4e8 into main Nov 23, 2026
3 checks passed
@jonathan-zenrows
jonathan-zenrows deleted the fix/extract-prepare-rejection-limit-not-allowance branch November 23, 2026 21:22
@github-actions github-actions Bot mentioned this pull request Nov 23, 2026
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.

2 participants