jackwener/OpenCLI · error · CommandExecutionError
pubmed search did not return an id list
Error message
pubmed search did not return an id list
What it means
This CommandExecutionError is thrown when the ESearch response for the core `pubmed search` command does not include a valid `esearchresult.idlist` array. The library treats the ESearch contract (idlist always present, even if empty) as mandatory; deviation means the request effectively failed or the API changed.
Source
Thrown at clis/pubmed/search.js:68
author: args.author,
journal: args.journal,
yearFrom,
yearTo,
articleType: args['article-type'],
hasAbstract: args['has-abstract'],
hasFullText: args['free-full-text'],
humanOnly: args['humans-only'],
englishOnly: args['english-only'],
});
const esearch = await eutilsFetch('esearch', {
term: searchQuery,
retmax: limit,
usehistory: 'y',
sort: sortMap[sort],
}, { label: 'pubmed search' });
const pmids = esearch?.esearchresult?.idlist;
if (!Array.isArray(pmids)) {
throw new CommandExecutionError('pubmed search did not return an id list', 'PubMed ESearch response shape may have changed.');
}
if (pmids.length === 0) {
throw new EmptyResultError('pubmed search', `No articles matched "${query}".`);
}
return fetchSummaryRows(pmids, 'pubmed search summary');
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Retry after a short backoff — rate limiting and transient errors are the most common cause
- Validate the query syntax (balanced quotes, correct field tags like [Author], [MeSH])
- Register an NCBI api_key and throttle requests to <=3/sec
- Log the raw esearch response to see the actual body and update the parser if NCBI changed the schema
Example fix
// before
clis.pubmedSearch({ query: '"machine learning AND [Title' });
// after
clis.pubmedSearch({ query: '"machine learning"[Title]' }); Defensive patterns
Strategy: retry
Validate before calling
// Basic query sanity before hitting the API
function assertValidPubMedQuery(q) {
const s = String(q);
const quotes = (s.match(/"/g) || []).length;
if (quotes % 2 !== 0) throw new Error('unbalanced quotes in query');
if (/\[(?!\w+\])/.test(s)) console.warn('possible malformed field tag in query');
} Type guard
function hasIdlist(res) {
return Array.isArray(res?.esearchresult?.idlist);
} Try / catch
try {
return await clis.pubmedSearch({ query, limit });
} catch (e) {
if (e.name === 'CommandExecutionError' && /did not return an id list/.test(e.message)) {
if (attempt < 3) { await sleep(2 ** attempt * 500); return retry(attempt + 1); }
}
throw e; // persistent failures: inspect raw body / schema
} Prevention
- Use exponential backoff with jitter and an api_key to stay under 3 req/sec
- Validate query syntax (quotes, [Field] tags) client-side before sending
- Log the raw esearch body on failure to distinguish rate limits from schema drift
- Cap retry attempts and surface the underlying cause rather than looping endlessly
When it happens
Trigger: PubMed returns an esearchresult containing an ERROR entry (bad query syntax like unbalanced quotes/field tags), rate-limit or HTML error bodies, eutilsFetch returning null/undefined, or an upstream schema change.
Common situations: Exceeding 3 anonymous requests/second to E-utilities; invalid query syntax (e.g. `author[Auther]`, stray quotes) causing an API-side error object; NCBI outage; aggressive retry loops getting throttled.
Related errors
- pubmed journal did not return an id list
- pubmed mesh did not return an id list
- pubmed review did not return an id list
- Bilibili ${label} API returned a malformed payload
- Bilibili ${label} API failed: ${message} (${payload.code})
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/76c797911bff4bb7.
Report an issue: GitHub.