Errors & retries
Cormorant reports problems on two levels:
- HTTP status codes — something is wrong with the request: the key, a limit, validation, or a wait that ran out.
- The
errorfield in search and fetch results — the request was fine, but the web said no: a 404, a robots.txt rule, a site that blocks every tier. These come with HTTP200(or as a batch item'serror).
HTTP status codes#
| Status | Body | Meaning | Retry? |
|---|---|---|---|
422 |
{"detail": [{"loc": […], "msg": "…", "type": "…"}]} or {"detail": "…"} |
Invalid request (a field out of range, a bad date, a non-http callback_url). |
No — fix the request. |
401 |
{"detail": "missing bearer token"} / {"detail": "invalid API key"} |
No key, or an unknown/revoked key. | No. |
403 |
{"detail": {"error": "customer_suspended", "message": "…"}} |
The account that owns the key's project is suspended (any /v1 endpoint). |
No — contact the operator. |
403 |
{"detail": {"error": "user_agent_not_allowed", "hint": "…"}} |
A user_agent that is not on the project allowlist. |
No — ask the operator or drop the field. |
404 |
{"detail": "job not found"} / {"detail": "body not found"} |
Unknown job or body, or one that belongs to another project (or has expired). | No. |
409 |
{"detail": "idempotency_key already used for a different job"} |
Same idempotency_key with a different kind or item count. |
No — use a new key. |
413 |
{"detail": "at most 50000 items per job"} |
Too many items (or a request body over 64 MB). | Split the job. |
403 |
{"detail": {"error": "key_category_not_allowed", "message": "…"}} |
The operator limited this key to other categories (e.g. search only). | No — use another key. |
429 |
{"detail": "rate limit exceeded"} + Retry-After: 1 |
Project rate limit. | Yes, after Retry-After. |
429 |
{"detail": {"error": "key_rate_limited", …}} + Retry-After: 1 |
The key's own requests-per-second limit. | Yes, after Retry-After. |
429 |
{"detail": {"error": "key_quota_exhausted", "category": "fetch", "limit": 100000, …}} |
The key used its monthly request quota for that category (search, fetch). Retry-After = seconds until the month resets. |
Not before the reset — see GET /v1/quota. |
429 |
{"detail": {"error": "key_budget_exhausted", "limit": "50.00", "currency": "USD", …}} |
The key reached its monthly spend cap. Retry-After = seconds until the month resets. |
Not before the reset. |
503 |
{"detail": "…"} |
A dependency is briefly unavailable (e.g. object storage while downloading a body). | Yes, with backoff. |
504 |
{"detail": {"error": "timeout", "request_id": "req_…"}} |
No result within the sync wait (150 s, or timeout_s + 15 s). |
Yes, later — the work often completes in the background and the retry is a cache hit. Better: use a batch. |
Fetch errors (error in the result)#
error |
Meaning |
|---|---|
invalid_url |
not an http(s) URL |
blocked_destination |
Cormorant's address safety check refused the host: it resolves to a private, loopback, link-local or metadata address (also after redirects), or is not a public host name. Not a policy about the site |
dns_error |
the host name did not resolve right now (SERVFAIL, a resolver timeout, a name without addresses; asked twice): retry after retry_after_s (60). Before API 1.2.0 this was blocked_destination with reason dns_error |
robots_disallowed |
robots.txt disallows the path for CormorantBot/* and premium routes are not allowed for this request (allow_premium: false, or the key has no premium requests left). By default robots.txt binds Cormorant's own addresses only (the operator can make it binding on every route): with premium routes allowed, a disallowed page skips direct and browser (attempts with reason robots_skip_own) and is fetched through the premium routes; the answer then has robots_disallowed: true, so you can filter such pages. Search, cart, login, account and similar URLs (reason: robots_low_value_path) are not fetched that way. Government hosts: robots.txt binds every route, the premium routes included — a page it disallows answers robots_disallowed whatever allow_premium says (see robots.txt and government hosts below). A project can keep robots.txt binding on every route for all hosts (project option respect_robots: strict, set by the operator). Wikimedia's APIs (/w/api.php, the Wikidata query service /sparql, /api/rest_v1/, Special:EntityData) are interfaces for programs: robots.txt does not apply to them, they are fetched directly with Cormorant's declared User-Agent |
source_terms |
the site's terms forbid automated access (Google Scholar, SSRN), so Cormorant never contacts it on any route and serves no cached copy, whatever tiers or the robots options say. For a paper with a DOI (SSRN papers have 10.2139/ssrn.<id>) Cormorant looks for an open copy elsewhere first (alternate_source: open_access). hint and alternative_urls say where else to look. |
too_large |
body exceeds its limit (see Size limits) |
pdf_not_accepted |
PDF with accept_pdf=false |
http_<status> |
definitive upstream status (e.g. http_404) |
all_tiers_failed |
every allowed tier failed or was blocked (status = last HTTP status; error_detail and premium_routes_tried say what was tried) |
domain_unavailable |
every tier failed for this domain in 3 consecutive fetches: it is skipped for a while (10 min, then 30 min, 2 h, 6 h; 5 min when a provider's own error was among the failures); retry_after_s says when to try again. Any success ends the skip |
domain_dead |
the host name does not exist (NXDOMAIN twice within 6 h); answered at once for 6 h, without trying. With allow_archive, a snapshot is returned instead when one exists (served_from_archive_because: "domain_dead") |
deadline |
batch fetch: the item's max_wait_s ran out before any page was fetched (attempts lists what was tried; reason says what it was waiting for) |
timeout |
timeout_s ran out (see per-request controls), or a large PDF took longer than 5 minutes to download (attempt reason pdf_download_timeout) |
no_tier_allowed |
tiers/allow_premium left no tier to try |
politeness_timeout |
could not get a per-domain slot in time (transient; batch items are requeued) |
domain_busy |
synchronous calls only, with HTTP 503 and Retry-After: the expected wait for one of the domain's polite slots exceeds the 15 s a synchronous call waits; retry_after_s is that expected wait. When the site already blocked Cormorant's own addresses in this request, the premium routes are tried first (the skipped own routes show as attempts with reason own_egress_busy), and domain_busy is answered only when they fail too. Lower the parallelism per domain or use a batch (whose items wait instead) |
sec_not_configured |
SEC EDGAR URL, but the operator has not configured Cormorant's SEC identity: SEC is disabled |
rate_limited |
SEC EDGAR URL: the cluster-wide SEC rate limit (at most 10 requests/s for all clients) had no slot within 10 s; retry after retry_after_s (transient) |
sec_unavailable |
SEC EDGAR throttled (403/429/503: all SEC requests back off), failed (5xx) or could not be reached; retry after retry_after_s (transient) |
redirect_not_allowed |
SEC EDGAR URL that redirected to a host outside SEC (not followed) |
premium_route_required |
a host fetched only through premium routes with allow_premium: false or a tiers list without proxy/proxy_render |
budget_exhausted |
such a host, and the project's budget leaves nothing for the premium routes |
Recent failures. A URL that answered http_404 or http_410 is answered
with that error for 24 hours, and one that ended in all_tiers_failed after
the premium routes were tried for 6 hours, without fetching it again: the
answer has cached: true, one attempt with tier recent and the
recorded reason, and retry_after_s says when it is
fetched again. Pass cache_ttl_s: 0 to fetch it now; a
success then clears the record. A request narrowed to some tiers (tiers)
is never recorded, but it is answered from a full-ladder failure.
robots.txt and government hosts
Since 2026-10-23, robots.txt is binding on every route for government
hosts: Cormorant's own addresses and the premium routes alike. A page such a
host's robots.txt disallows for CormorantBot/* answers
error: "robots_disallowed" and is not fetched; such hosts never answer with
robots_disallowed: true. A host is a government host when
- its top-level domain is
.gov,.milor.int; - it is under a government second-level domain of a country code:
gov.<cc>(.gov.uk,.gov.au,.gov.cn,.gov.in,.gov.br,.gov.it…),govt.<cc>(.govt.nz),gouv.<cc>(.gouv.fr,.gouv.qc.ca),gob.<cc>(.gob.mx,.gob.es),gv.<cc>(.gv.at),gub.<cc>,mil.<cc>, andgo.<cc>forjp,kr,id,th,ke,tz,ug,cr,ci,bw,zm(.go.jp,.go.kr…); - or it is, or is under, one of:
admin.ch,ch.ch, the Swiss cantons' domains (zh.ch,be.ch,vd.ch… all 26),llv.li,bund.de,bundesregierung.de,bundestag.de,europa.eu,gc.ca,canada.ca,fgov.be,belgium.be,overheid.nl,rijksoverheid.nl,parliament.uk,police.uk,nhs.uk.
The operator can exempt single hosts from robots.txt (hosts that serve
published open data files for download). Such a host is fetched from
Cormorant's own addresses, and access reports name the exemption instead of
calling the path allowed. A project with respect_robots: strict keeps
robots.txt binding for these hosts too.
The operator can exempt a project (project option respect_robots: own_addresses: robots.txt then binds Cormorant's own addresses only, also for
government hosts). Allowed paths of government hosts are fetched as before.
When no tier reaches min_text_chars, the best capture is returned with
error: null, thin_content: true and text_complete: false: a live capture
always before an archived (tier: archive) one, then the one with the most
text. It is never a plain success — check thin_content (or text_complete)
before relying on the text. A PDF without extractable text (a scan without
a text layer) is returned with pdf_no_text: true, text: "" and
text_complete: false; its bytes are in body_url (Cormorant does no OCR).
Both flags are additive fields: existing clients see the same error and
tier as before.
min_text_chars counts Latin-script characters of the same content: a
Chinese or Japanese character counts as three, a Korean one as two, a Thai
one as 1.3, so the default 500 fits pages in every language (a whole Chinese
news story is often under 500 characters).
lang is the language of text: the page's own tag (<html lang>, JSON-LD
inLanguage, og:locale; lang_source: declared) when the text agrees with
it or is too short to tell, else the language detected from the text
(detected, e.g. a translated page that kept its template's lang="en").
Chinese always carries its script (zh-Hans, zh-Hant), told apart by the
characters only one of them uses; a declared region is kept (zh-Hant-TW).
meta.language stays the page's declaration as written. Pages in GBK/GB2312,
Big5, Shift_JIS, EUC-JP and EUC-KR decode correctly also when the charset is
undeclared or labelled with the narrower legacy name.
error |
Retry? |
|---|---|
invalid_url, blocked_destination |
No. |
robots_disallowed |
No — the site asked crawlers not to fetch this path. |
source_terms |
No — the site's terms forbid automated access (Google Scholar, SSRN). Use the open copy, alternative_urls, or open the page yourself. |
too_large, pdf_not_accepted, no_tier_allowed |
Not as is — change max_bytes, accept_pdf, tiers or allow_premium. |
http_404, http_410 and other definitive http_<status> |
No (perhaps much later, if the page may reappear). For 404/410, archive_snapshot / alternative_urls point at the page's closest Wayback Machine snapshot when there is one. |
all_tiers_failed |
Later (hours), or with premium routes allowed if you had allow_premium: false. Look at attempts (and error_detail, premium_routes_tried) to see what blocked and what it cost. A domain that refused the premium routes on recent fetches skips them for a while (premium_skipped_domain_refuses). |
timeout |
Yes, with a larger timeout_s — or in a batch. |
domain_unavailable |
Not before retry_after_s seconds — earlier requests get the same answer at once, without trying. Try another source meanwhile. |
domain_dead |
No (hours at the earliest) — the host name does not exist. Look for the page elsewhere; with allow_archive (the default) you already got the archived copy when there is one. |
politeness_timeout |
Yes, after a short pause: the domain was busy. Batches handle this for you. |
domain_busy (HTTP 503, sync only) |
Yes, after retry_after_s (also in Retry-After): the domain's polite slots are taken for longer than a synchronous call waits. Send fewer parallel calls per domain, or use a batch. |
rate_limited, sec_unavailable |
Yes, after retry_after_s (SEC EDGAR's shared rate limit or backoff). Batches handle this for you. |
sec_not_configured |
No — SEC EDGAR is not enabled on this deployment; ask the operator. |
redirect_not_allowed |
No — an SEC EDGAR URL redirected outside SEC. |
Batch items are retried automatically for transient problems (connection
errors, politeness timeouts, provider rate limits); what ends up in an item's
error is final for that job.
Paper errors#
GET /v1/papers/{id} answers 422 invalid_paper_id for text that is not an
identifier it reads, 404 paper_not_found when no source knows the paper,
and 410 paper_removed (with notice) for a paper taken down.
GET /v1/papers/{id}/fulltext answers 403 licence_restricted when no copy
of the paper has a licence that allows reuse (CC BY-NC, CC BY-ND, publisher
terms or none stated) and 404 fulltext_unavailable when no reusable copy
could be read now; both list the copies in links to read under their
licence. Neither is charged. A search with
a source that did not answer is not an error: partial: true, and
sources_status says which source and why.
Search errors#
A search whose providers could not answer returns results: [] and error —
for example budget_exhausted (no budget left for the fallback search service),
brave_http_429 (the fallback was rate-limited) or a SearXNG failure such as
searxng_timeout. These are transient: retry later with backoff. A search
that the engines answered but that found nothing is not an error:
results: [] with error: null — rephrase the query instead of retrying.
Backoff#
Retry only what is retryable, cap the number of attempts, and back off
exponentially with jitter. Respect Retry-After when present.
import random
import time
import httpx
RETRY_STATUS = {429, 502, 503, 504} # but not key_quota/budget_exhausted: see below
def post_with_retries(client: httpx.Client, path: str, body: dict, attempts: int = 5) -> dict:
for attempt in range(attempts):
try:
response = client.post(path, json=body)
except httpx.TransportError:
response = None
if response is not None and response.status_code not in RETRY_STATUS:
response.raise_for_status() # 4xx other than 429: do not retry
return response.json()
if attempt == attempts - 1:
break
retry_after = response.headers.get("retry-after") if response is not None else None
delay = (
float(retry_after) if retry_after else min(60, 2**attempt) * random.uniform(0.5, 1.5)
)
time.sleep(delay)
raise RuntimeError(f"{path} failed after {attempts} attempts")
const RETRY_STATUS = new Set([429, 502, 503, 504]);
async function postWithRetries(path: string, body: unknown, attempts = 5): Promise<any> {
for (let attempt = 0; attempt < attempts; attempt++) {
let res: Response | undefined;
try {
res = await fetch(`${BASE}${path}`, { method: "POST", headers, body: JSON.stringify(body) });
} catch {
res = undefined; // network error: retry
}
if (res && !RETRY_STATUS.has(res.status)) {
if (!res.ok) throw new Error(`${res.status}: ${await res.text()}`);
return res.json();
}
if (attempt === attempts - 1) break;
const retryAfter = Number(res?.headers.get("retry-after"));
const delay = retryAfter > 0 ? retryAfter * 1000 : Math.min(60_000, 2 ** attempt * 1000) * (0.5 + Math.random());
await new Promise((r) => setTimeout(r, delay));
}
throw new Error(`${path} failed after ${attempts} attempts`);
}
A fetch that returns 200 with an error is a result. Decide per code with
the table above whether to retry it later; do not loop on it immediately.
Debugging#
Every response and every batch item has a request_id. attempts shows each
tier with its HTTP status, reason (challenge_cloudflare, http_403,
thin_content, timeout, …) and duration. When you ask the operator about a
request, send the request_id.