jackwener/OpenCLI · warning · EmptyResultError
No items match "${query}" on archive.org.
Error message
No items match "${query}" on archive.org. What it means
EmptyResultError thrown by `opencli archive search` when the archive.org advancedsearch API responds successfully but returns zero hits in response.docs. This is not a failure of the API call itself; the query parsed and executed, it simply matched nothing. The library converts an empty result set into a typed error so callers can distinguish 'no data' from 'broken payload' or 'network failure'.
Source
Thrown at clis/archive/search.js:90
} 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.`);
}
return docs.slice(0, limit).map((d, i) => {
const id = String(d.identifier ?? '');
if (!IDENTIFIER_RE.test(id)) {
throw new CommandExecutionError('archive search returned malformed payload: result row is missing a stable identifier');
}
const downloads = Number(d.downloads ?? 0);
if (!Number.isFinite(downloads)) {
throw new CommandExecutionError(`archive search returned malformed payload for "${id}": downloads must be numeric`);
}
const creator = Array.isArray(d.creator) ? d.creator.join(', ') : String(d.creator ?? '');
return {
rank: i + 1,
identifier: id,
title: String(d.title ?? ''),
creator,
date: d.date ? String(d.date).slice(0, 10) : '',View on GitHub (pinned to 49907e53dc)
Solutions
- Broaden the search query: remove quoted phrases, field filters, or extra keywords and retry.
- Check spelling of the query terms and any field:value filters.
- Verify the item still exists by browsing https://archive.org directly for the same terms.
- If the empty result is expected in your workflow, catch EmptyResultError explicitly and treat it as a normal 'no rows' outcome.
Example fix
// before opencli archive search 'collection:missingcollection AND title:"exact phrase"' // after opencli archive search 'collection:missingcollection' # broaden, then refine
Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-check the same query against the advancedsearch API before relying on results
const api = `https://archive.org/advancedsearch.php?q=${encodeURIComponent(query)}&fl[]=identifier&rows=1&output=json`;
const data = await (await fetch(api)).json();
const hasHits = Array.isArray(data?.response?.docs) && data.response.docs.length > 0;
if (!hasHits) console.warn('query will return no archive.org items'); Type guard
function hasDocs(data) {
return Array.isArray(data?.response?.docs) && data.response.docs.length > 0;
} Try / catch
try {
const rows = await run(['archive', 'search', query]);
} catch (e) {
if (e instanceof EmptyResultError || /No items match/.test(e.message)) {
return []; // treat empty as a normal result
}
throw e;
} Prevention
- Test queries interactively on archive.org before scripting them.
- Start broad, then add field filters incrementally.
- Explicitly handle empty-result errors as a valid outcome in pipelines.
When it happens
Trigger: Running `opencli archive search <query>` where the HTTP request succeeds (resp.ok), the JSON parses, response.docs is an array, but that array has length 0.
Common situations: Misspelled search terms; over-restrictive query syntax (e.g. quoted phrases or field filters like mediatype: that match nothing); searching for identifiers/items that have been removed from archive.org; typos in metadata fields used in the query.
Understand the failure class
Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.
Related errors
- No hotels rendered (${totalText}). Try a broader destination
- No WeRead books found for "${bookQuery}"
- archive snapshots url cannot be empty
- archive snapshots limit must be a positive integer
- dongchedi search "${keyword}": No car series matched. Try th
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/c1561cc3ca2f1e58.
Report an issue: GitHub.