jackwener/OpenCLI · info · EmptyResultError

pubmed journal

Error message

pubmed journal

What it means

This EmptyResultError is thrown when the PubMed ESearch for the given journal succeeded but returned zero PMIDs, i.e. no articles matched the journal (and optional year range) query. The first argument is the command name 'pubmed journal'; the message includes the journal name. It signals a valid-but-empty search, not a failure.

Source

Thrown at clis/pubmed/journal.js:55

            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 journal' });
        const pmids = esearch?.esearchresult?.idlist;
        if (!Array.isArray(pmids)) {
            throw new CommandExecutionError('pubmed journal did not return an id list', 'PubMed ESearch response shape may have changed.');
        }
        if (pmids.length === 0) {
            throw new EmptyResultError('pubmed journal', `No articles found for journal "${journal}".`);
        }
        return fetchSummaryRows(pmids, 'pubmed journal summary');
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Check the journal name/abbreviation against the NCBI Journal List (use the MEDLINE abbreviation, e.g. 'N Engl J Med')
  2. Widen or remove the year-from/year-to range
  3. Reduce other query constraints (sort/limit do not affect matching, but review any extra terms)
  4. Verify with a plain pubmed search that the journal string matches anything

Example fix

// before
clis.pubmedJournal({ journal: 'The New England Journal of Medicine', yearFrom: 2024, yearTo: 2024 });
// after
clis.pubmedJournal({ journal: 'N Engl J Med' });
Defensive patterns

Strategy: fallback

Validate before calling

// Pre-flight: check the journal abbreviation resolves via a cheap ESearch count
const probe = await eutilsFetch('esearch', { term: `${journal}[Journal]`, retmax: 0 }, { label: 'probe' });
const count = Number(probe?.esearchresult?.count ?? 0);
if (count === 0) console.warn(`No PubMed articles for journal "${journal}"`);

Try / catch

try {
  return await clis.pubmedJournal({ journal, yearFrom, yearTo });
} catch (e) {
  if (e.name === 'EmptyResultError' && e.scope === 'pubmed journal') {
    return []; // or suggest corrected journal spellings
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling the journal command with a misspelled or non-existent journal abbreviation (e.g. 'Nature Genetix'); a year range where the journal had no articles; using the full journal name where PubMed expects the MEDLINE abbreviation, so `journal[X]` matches nothing.

Common situations: Typo in journal name; using 'The Lancet' instead of 'Lancet'; overly narrow year-from/year-to window; querying a very new or discontinued journal with no indexed matches.

Related errors


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