jackwener/OpenCLI · error · CommandExecutionError
archive search request failed: ${error?.message || error}
Error message
archive search request failed: ${error?.message || error} What it means
This CommandExecutionError wraps any network-level failure of the fetch to archive.org's advancedsearch endpoint during `archive search`. It fires when fetch itself rejects (DNS failure, connection refused/reset, TLS error, timeout, abort) — as opposed to a non-2xx HTTP status, which produces a separate 'archive search failed: HTTP <status>' error. The original error message is interpolated into the message.
Source
Thrown at clis/archive/search.js:73
const url = new URL('https://archive.org/advancedsearch.php');
url.searchParams.set('q', fullQuery);
url.searchParams.set('output', 'json');
url.searchParams.set('rows', String(limit));
url.searchParams.set('sort[]', `${sort} desc`);
for (const fl of ['identifier', 'title', 'creator', 'date', 'mediatype', 'downloads']) {
url.searchParams.append('fl[]', fl);
}
let resp;
try {
resp = await fetch(url, {
headers: {
'Accept': 'application/json',
'User-Agent': 'opencli/1.0 (+https://github.com/jackwener/opencli)',
},
});
} catch (error) {
throw new CommandExecutionError(`archive search request failed: ${error?.message || error}`);
}
if (!resp.ok) {
throw new CommandExecutionError(`archive search failed: HTTP ${resp.status}`);
}
let data;
try {
data = await resp.json();
} catch (error) {
throw new CommandExecutionError(`archive search returned malformed JSON: ${error?.message || error}`);
}
const docs = data?.response?.docs;
if (!Array.isArray(docs)) {
throw new CommandExecutionError('archive search returned malformed payload: response.docs must be an array');
}
if (docs.length === 0) {
throw new EmptyResultError('archive search', `No items match "${query}" on archive.org.`);
}View on GitHub (pinned to 49907e53dc)
Solutions
- Check basic connectivity (`curl -I https://archive.org`) and DNS resolution
- Configure proxy environment variables (HTTPS_PROXY/HTTPS_PROXY) if behind a corporate proxy
- Retry after a short backoff — transient network blips and archive.org incidents resolve themselves
- Inspect the interpolated cause in the message (e.g. 'getaddrinfo ENOTFOUND') and fix the specific network issue it names
Example fix
// before
const rows = await run(['archive', 'search', 'jazz']);
// after
let rows;
try {
rows = await run(['archive', 'search', 'jazz']);
} catch (err) {
if (/request failed/.test(String(err?.message))) {
rows = await run(['archive', 'search', 'jazz']); // retry once after transient network failure
} else {
throw err;
}
} Defensive patterns
Strategy: retry
Validate before calling
// probe connectivity before batch runs
const ok = await fetch('https://archive.org/', { method: 'HEAD' }).then(r => r.ok).catch(() => false);
if (!ok) throw new Error('archive.org unreachable; check network/proxy'); Type guard
null
Try / catch
try {
rows = await run(['archive', 'search', query]);
} catch (err) {
if (err instanceof CommandExecutionError && err.message.includes('request failed')) {
await new Promise(r => setTimeout(r, 1000));
rows = await run(['archive', 'search', query]); // single retry for transient network errors
} else { throw err; }
} Prevention
- Set HTTPS_PROXY correctly in corporate environments
- Add timeout/retry with exponential backoff around CLI invocations
- Probe connectivity once before batch jobs
- Log the interpolated cause (DNS vs TLS vs reset) to target fixes
When it happens
Trigger: Calling `opencli archive search ...` while offline or with DNS failures; a proxy/firewall blocking archive.org; TLS interception breaking the handshake; connection reset or socket timeout mid-request.
Common situations: Corporate networks requiring a proxy that is not configured (HTTPS_PROXY); VPN drops mid-command; archive.org outage or rate-limiting at the TCP level; IPv6 misresolution in containers.
Related errors
- archive search returned malformed JSON: ${error?.message ||
- coingecko trending request failed: ${error?.message || error
- FETCH_ERROR
- hf paper request failed: ${err?.message ?? err}
- hf spaces request failed: ${err?.message ?? err}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/cd71cb334b4716ad.
Report an issue: GitHub.