{"record":{"id":"7af48544d8159876","repo":"jackwener/OpenCLI","slug":"archive-wayback-request-failed-error-message","errorCode":null,"errorMessage":"archive wayback request failed: ${error?.message || error}","messagePattern":"archive wayback request failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/archive/wayback.js","lineNumber":55,"sourceCode":"                'Example: opencli archive wayback wikipedia.org',\n            );\n        }\n        const timestamp = args.timestamp ? normalizeTimestamp(args.timestamp) : '';\n\n        const apiUrl = new URL('https://archive.org/wayback/available');\n        apiUrl.searchParams.set('url', target);\n        if (timestamp) apiUrl.searchParams.set('timestamp', timestamp);\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 wayback request failed: ${error?.message || error}`);\n        }\n        if (!resp.ok) {\n            throw new CommandExecutionError(`archive wayback failed: HTTP ${resp.status}`);\n        }\n        let data;\n        try {\n            data = await resp.json();\n        } catch (error) {\n            throw new CommandExecutionError(`archive wayback returned malformed JSON: ${error?.message || error}`);\n        }\n\n        const snap = data?.archived_snapshots?.closest;\n        if (!snap || !snap.available) {\n            throw new EmptyResultError('archive wayback', `No Wayback snapshot for \"${target}\".`);\n        }\n        if (typeof snap.url !== 'string' || !snap.url || !/^\\d{14}$/.test(String(snap.timestamp ?? ''))) {\n            throw new CommandExecutionError('archive wayback returned malformed payload: closest snapshot is missing url/timestamp');\n        }","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/archive/wayback.js#L37-L73","documentation":"The `archive wayback` command fetches `https://archive.org/wayback/available` to resolve the closest snapshot. This CommandExecutionError is thrown when the `fetch` itself rejects — the request never got an HTTP response — wrapping the underlying network error message. It is distinct from the HTTP-status error, which is reported separately as `archive wayback failed: HTTP <status>`.","triggerScenarios":"DNS resolution failure for archive.org, connection refused/timeout, TLS handshake errors, offline environment, IPv6 connectivity issues, or a proxy/firewall blocking archive.org — any condition where fetch throws instead of returning a response.","commonSituations":"Running in CI containers without egress to archive.org; DNS blockers (Pi-hole, corporate allowlists) rejecting archive.org; transient archive.org outages; misconfigured HTTP(S)_PROXY environment variables; Node versions lacking proper CA certificates for TLS.","solutions":["Retry the command — most fetch failures against archive.org are transient outages.","Verify basic connectivity: `curl -I https://archive.org/wayback/available?url=example.com`.","Check DNS/firewall/proxy configuration (HTTPS_PROXY, allowlists, Pi-hole block lists).","Confirm TLS works from your runtime (update CA certificates / Node version) if you see certificate errors in the wrapped message."],"exampleFix":"// before: fail hard on transient outage\nawait exec('opencli archive wayback example.com');\n// after: retry once after a short delay\ntry {\n  await exec('opencli archive wayback example.com');\n} catch {\n  await new Promise(r => setTimeout(r, 3000));\n  await exec('opencli archive wayback example.com');\n}","handlingStrategy":"retry","validationCode":"// Pre-flight reachability check\nconst ok = await fetch('https://archive.org/wayback/available?url=example.com', { method: 'HEAD' })\n  .then(() => true).catch(() => false);\nif (!ok) console.warn('archive.org unreachable');","typeGuard":null,"tryCatchPattern":"try {\n  await exec('opencli archive wayback example.com');\n} catch (e) {\n  if (String(e.message).includes('archive wayback request failed')) {\n    // network-level failure: retry with backoff, check proxy/DNS\n  } else throw e;\n}","preventionTips":["Add retry-with-backoff for archive.org calls in scripts","Ensure HTTPS_PROXY/NO_PROXY and DNS allowlists permit archive.org","Run a curl pre-flight in CI before batch jobs","Keep CA certificates and Node runtime up to date"],"tags":["network","dns","fetch","wayback-machine","timeout"],"backgroundTag":"network-request-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}