jackwener/OpenCLI · error · CommandExecutionError
archive snapshots failed: HTTP ${resp.status}
Error message
archive snapshots failed: HTTP ${resp.status} What it means
CommandExecutionError thrown when the Wayback CDX endpoint responds with a non-2xx HTTP status. The CDX service commonly returns 503 (per its docs, served on HTTP; HTTPS returns 503) or 4xx/5xx under load. The status code is embedded in the message so callers can branch on it.
Source
Thrown at clis/archive/snapshots.js:79
apiUrl.searchParams.set('url', target);
apiUrl.searchParams.set('output', 'json');
apiUrl.searchParams.set('limit', String(limit));
if (args.from) apiUrl.searchParams.set('from', String(args.from));
if (args.to) apiUrl.searchParams.set('to', String(args.to));
let resp;
try {
resp = await fetch(apiUrl, {
headers: {
'Accept': 'application/json',
'User-Agent': 'opencli/1.0 (+https://github.com/jackwener/opencli)',
},
});
} catch (error) {
throw new CommandExecutionError(`archive snapshots request failed: ${error?.message || error}`);
}
if (!resp.ok) {
throw new CommandExecutionError(`archive snapshots failed: HTTP ${resp.status}`);
}
let data;
try {
data = await resp.json();
} catch (error) {
throw new CommandExecutionError(`archive snapshots returned malformed JSON: ${error?.message || error}`);
}
// CDX returns an array of arrays; the first row is the header.
if (!Array.isArray(data)) {
throw new CommandExecutionError('archive snapshots returned malformed CDX payload: top-level payload must be an array');
}
if (data.length < 2) {
throw new EmptyResultError('archive snapshots', `No Wayback snapshots for "${target}".`);
}
const [header, ...rows] = data;
if (!Array.isArray(header)) {
throw new CommandExecutionError('archive snapshots returned malformed CDX payload: header row must be an array');View on GitHub (pinned to 49907e53dc)
Solutions
- Check the status in the message: 503 usually means retry later with exponential backoff.
- Verify the target url pattern is valid CDX syntax (e.g. example.org or example.org/* for prefix matches).
- Slow down request rate and add caching if you query many sites — Wayback enforces rate limits.
- Confirm you are hitting the HTTP endpoint; the HTTPS CDX endpoint is known to return 503.
Example fix
// before opencli archive snapshots 'https://example.org/path with space' // after opencli archive snapshots 'example.org/*' # valid CDX url pattern, then retry on 503
Defensive patterns
Strategy: retry
Validate before calling
// Validate the CDX url pattern before calling
classic: pattern = pattern || 'example.org';
if (/[<>"'\s]/.test(pattern)) throw new Error(`invalid CDX url pattern: ${pattern}`);
if (!Number.isInteger(limit) || limit <= 0 || limit > 1000) throw new Error('limit must be 1..1000'); Try / catch
try {
await run(['archive', 'snapshots', url]);
} catch (e) {
const m = /HTTP (\d{3})/.exec(e.message);
if (m) {
const status = Number(m[1]);
if (status === 503 || status === 429) return retryWithBackoff(url); // transient
throw e; // 4xx: fix the url pattern/query
}
throw e;
} Prevention
- Retry automatically on 503/429; fix the query on 4xx.
- Throttle batch queries to respect Wayback rate limits.
- Use valid CDX url patterns (domain or domain/*) to avoid 400s.
- Cache snapshot results to reduce repeat hits on the CDX endpoint.
When it happens
Trigger: The fetch to http://web.archive.org/cdx/search/cdx succeeds at the transport level but resp.ok is false — e.g. HTTP 503 from overload or from hitting the HTTPS endpoint, 400 for a malformed url param, 403 for blocked clients.
Common situations: Wayback rate-limiting heavy automated use; CDX under maintenance/overload; malformed CDX query parameters (bad url= pattern, invalid filters); intermediaries returning 4xx/5xx HTML pages.
Related errors
- archive snapshots request failed: ${error?.message || error}
- Instagram private publish ${stage} failed: ${response.status
- Failed to fetch followers: HTTP ' + r2.status
- Failed to fetch following: HTTP ' + r2.status
- 1point3acres request failed: HTTP ${res.status} ${res.status
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/3fdd85101edcb74c.
Report an issue: GitHub.