jackwener/OpenCLI · info · EmptyResultError

pubmed mesh

Error message

pubmed mesh

What it means

This EmptyResultError ('pubmed mesh') is thrown when the ESearch for the given MeSH term succeeded but returned zero PMIDs. The search was valid; PubMed simply has no articles indexed under that MeSH term (with the given sort/limit options). It is a no-results signal, not an API failure.

Source

Thrown at clis/pubmed/mesh.js:43

    ],
    columns: SEARCH_COLUMNS,
    func: async (args) => {
        const term = requireText(args.term, 'term');
        const limit = requireBoundedInt(args.limit, 20, 100);
        const sort = requireChoice(args.sort, ['relevance', 'date'], 'sort', 'relevance');
        const tag = args.major ? 'Majr' : 'MeSH Terms';
        const esearch = await eutilsFetch('esearch', {
            term: `${term}[${tag}]`,
            retmax: limit,
            usehistory: 'y',
            sort: sort === 'date' ? 'pub_date' : '',
        }, { label: 'pubmed mesh' });
        const pmids = esearch?.esearchresult?.idlist;
        if (!Array.isArray(pmids)) {
            throw new CommandExecutionError('pubmed mesh did not return an id list', 'PubMed ESearch response shape may have changed.');
        }
        if (pmids.length === 0) {
            throw new EmptyResultError('pubmed mesh', `No articles found for MeSH term "${term}".`);
        }
        return fetchSummaryRows(pmids, 'pubmed mesh summary');
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Verify the exact MeSH heading via the NCBI MeSH Browser and use it verbatim (including commas/qualifiers like '[MeSH Terms]')
  2. Use a broader parent heading (e.g. 'Neoplasms' instead of a very specific subtype)
  3. Fall back to a plain pubmed search with the term as free text
  4. Retry a differently-cased/normalized term (e.g. 'COVID-19', 'SARS-CoV-2')

Example fix

// before
clis.pubmedMesh({ term: 'heart attack' });
// after
clis.pubmedMesh({ term: 'Myocardial Infarction' });
Defensive patterns

Strategy: fallback

Validate before calling

// Pre-flight: confirm the MeSH heading exists and has hits
const probe = await eutilsFetch('esearch', { term: `${term}[MeSH Terms]`, retmax: 0 }, { label: 'probe' });
if (Number(probe?.esearchresult?.count ?? 0) === 0) console.warn(`No articles for MeSH term "${term}"`);

Try / catch

try {
  return await clis.pubmedMesh({ term, limit });
} catch (e) {
  if (e.name === 'EmptyResultError' && e.scope === 'pubmed mesh') {
    return clis.pubmedSearch({ query: term }); // fall back to free-text search
  }
  throw e;
}

Prevention

When it happens

Trigger: Passing a term that is not a valid MeSH heading (e.g. 'Covid-19' instead of the indexed 'COVID-19'), using free text that maps to no MeSH article set, or combining the term with a filter that eliminates everything.

Common situations: Non-MeSH vocabulary or lay terms ('heart attack' vs 'Myocardial Infarction'); very new topics not yet MeSH-indexed; qualifiers written in the wrong format; expecting the term to be treated as free text when it is matched strictly.

Related errors


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