{"record":{"id":"495d7d13d00f62d6","repo":"jackwener/OpenCLI","slug":"archive-snapshots-request-failed-error-message","errorCode":null,"errorMessage":"archive snapshots request failed: ${error?.message || error}","messagePattern":"archive snapshots request failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/archive/snapshots.js","lineNumber":76,"sourceCode":"\n        // Wayback CDX is served on HTTP only; the HTTPS endpoint returns 503.\n        const apiUrl = new URL('http://web.archive.org/cdx/search/cdx');\n        apiUrl.searchParams.set('url', target);\n        apiUrl.searchParams.set('output', 'json');\n        apiUrl.searchParams.set('limit', String(limit));\n        if (args.from) apiUrl.searchParams.set('from', String(args.from));\n        if (args.to) apiUrl.searchParams.set('to', String(args.to));\n\n        let resp;\n        try {\n            resp = await fetch(apiUrl, {\n                headers: {\n                    'Accept': 'application/json',\n                    'User-Agent': 'opencli/1.0 (+https://github.com/jackwener/opencli)',\n                },\n            });\n        } catch (error) {\n            throw new CommandExecutionError(`archive snapshots request failed: ${error?.message || error}`);\n        }\n        if (!resp.ok) {\n            throw new CommandExecutionError(`archive snapshots failed: HTTP ${resp.status}`);\n        }\n        let data;\n        try {\n            data = await resp.json();\n        } catch (error) {\n            throw new CommandExecutionError(`archive snapshots returned malformed JSON: ${error?.message || error}`);\n        }\n\n        // CDX returns an array of arrays; the first row is the header.\n        if (!Array.isArray(data)) {\n            throw new CommandExecutionError('archive snapshots returned malformed CDX payload: top-level payload must be an array');\n        }\n        if (data.length < 2) {\n            throw new EmptyResultError('archive snapshots', `No Wayback snapshots for \"${target}\".`);\n        }","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/archive/snapshots.js#L58-L94","documentation":"CommandExecutionError wrapping any exception (network error, DNS failure, timeout, fetch rejection) raised while requesting the Wayback CDX API at http://web.archive.org/cdx/search/cdx. The original error message is preserved in the new message via `error?.message || error`. Note the library deliberately uses HTTP because the HTTPS CDX endpoint returns 503.","triggerScenarios":"fetch() rejects during `opencli archive snapshots <url>`: DNS resolution failure, connection refused/reset, TLS interception problems, request timeout, or offline network.","commonSituations":"Being offline or behind a corporate proxy/firewall blocking web.archive.org; DNS misconfiguration; corporate MITM proxies breaking plain-HTTP requests; Wayback temporarily unreachable or rate-limiting.","solutions":["Check network connectivity and confirm web.archive.org is reachable: curl -I http://web.archive.org/cdx/search/cdx?url=example.org&output=json","If behind a proxy, configure HTTP_PROXY/HTTPS_PROXY correctly for the runtime.","Retry after a short delay — Wayback CDX is often intermittently overloaded; backoff on repeated failures.","Ensure your environment does not force an HTTPS upgrade that breaks the HTTP-only CDX endpoint."],"exampleFix":"// retry wrapper around the CLI call\nfor (let i = 0; i < 3; i++) {\n  try { return await runSnapshots(url); }\n  catch (e) {\n    if (!String(e.message).includes('request failed')) throw e;\n    await new Promise(r => setTimeout(r, 2 ** i * 1000));\n  }\n}","handlingStrategy":"retry","validationCode":"// Reachability pre-check before running the command\nconst ok = await fetch('http://web.archive.org/cdx/search/cdx?url=example.org&output=json&limit=1')\n  .then(r => r.ok).catch(() => false);\nif (!ok) console.warn('web.archive.org unreachable; check network/proxy');","typeGuard":null,"tryCatchPattern":"async function withRetry(fn, attempts = 3) {\n  for (let i = 0; i < attempts; i++) {\n    try { return await fn(); }\n    catch (e) {\n      if (!/snapshots request failed/.test(e.message) || i === attempts - 1) throw e;\n      await new Promise(r => setTimeout(r, 2 ** i * 1000));\n    }\n  }\n}","preventionTips":["Set HTTP_PROXY/HTTPS_PROXY when behind corporate proxies.","Add exponential backoff for archive.org calls in automation.","Monitor web.archive.org status before large batch jobs.","Remember the CDX API is HTTP-only; do not force HTTPS upgrades."],"tags":["network","http-request","archive-org","wayback"],"backgroundTag":"request-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}