jackwener/OpenCLI · info · EmptyResultError

pubmed author

Error message

pubmed author

What it means

EmptyResultError('pubmed author') thrown at clis/pubmed/author.js:60 when ESearch succeeded and returned a valid idlist array, but the array is empty — i.e. no PubMed articles match the constructed author query (name[author-tag] plus optional affiliation and date-range terms). This is a legitimate 'no results' outcome, not an API failure.

Source

Thrown at clis/pubmed/author.js:60

            const from = yearFrom || 1800;
            const to = yearTo || new Date().getFullYear();
            if (from > to) {
                throw new ArgumentError('pubmed year-from must be <= year-to');
            }
            terms.push(`${from}:${to}[PDAT]`);
        }
        const esearch = await eutilsFetch('esearch', {
            term: terms.join(' AND '),
            retmax: limit,
            usehistory: 'y',
            sort: sort === 'date' ? 'pub_date' : '',
        }, { label: 'pubmed author' });
        const pmids = esearch?.esearchresult?.idlist;
        if (!Array.isArray(pmids)) {
            throw new CommandExecutionError('pubmed author did not return an id list', 'PubMed ESearch response shape may have changed.');
        }
        if (pmids.length === 0) {
            throw new EmptyResultError('pubmed author', `No articles found for author "${name}".`);
        }
        return fetchSummaryRows(pmids, 'pubmed author summary');
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Simplify the query: search the surname plus initials only, without affiliation or year filters, and confirm hits exist
  2. Try alternative name formats ('Smith JA', 'Smith, John A') — PubMed author indexing is format-sensitive
  3. Widen the year range or drop the affiliation term, then re-narrow gradually
  4. Use PubMed's advanced search in a browser to verify the author has indexed publications
  5. Check the authorTag used in the term construction matches PubMed's field tags (e.g. [Author] vs [1au])

Example fix

// before
await runCli('pubmed author "Jane Q Doe"', { affiliation: 'Acme Genomics Lab', 'year-from': 2024, 'year-to': 2024 });
// after
await runCli('pubmed author "Doe J"', {}); // start broad, then narrow with affiliation/year filters
Defensive patterns

Strategy: try-catch

Validate before calling

// sanity-check the author string format before searching
const normalized = name.trim();
if (!/^[\p{L}'\-., ]+$/u.test(normalized) || normalized.length < 2) {
  throw new Error(`"${name}" does not look like an author name`);
}

Try / catch

try {
  const rows = await runCli('pubmed author', { name });
} catch (e) {
  if (e instanceof EmptyResultError || /No articles found for author/.test(e.message)) {
    console.warn(`No PubMed hits for "${name}" — try surname + initials format.`);
    return [];
  }
  throw e;
}

Prevention

When it happens

Trigger: esearchresult.idlist exists but length === 0 because: (a) the author name is misspelled or uses an uncommon format ('Smith J' vs 'Smith, John'), (b) the affiliation [ad] term or year range is too restrictive, (c) sort pub_date combined with filters excludes all hits, (d) the author has no PubMed-indexed publications.

Common situations: Searching a nickname/maiden name; adding an affiliation string that doesn't match how it appears in PubMed's [ad] index; a narrow year window missing the author's active period; searching for a non-researcher or non-PubMed-indexed author.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/6efd62636822d9b0. Report an issue: GitHub.