{"record":{"id":"2d981d1f4b366bcf","repo":"jackwener/OpenCLI","slug":"pubmed-mesh","errorCode":null,"errorMessage":"pubmed mesh","messagePattern":"pubmed mesh","errorType":"exception","errorClass":"EmptyResultError","httpStatus":null,"severity":"info","filePath":"clis/pubmed/mesh.js","lineNumber":43,"sourceCode":"    ],\n    columns: SEARCH_COLUMNS,\n    func: async (args) => {\n        const term = requireText(args.term, 'term');\n        const limit = requireBoundedInt(args.limit, 20, 100);\n        const sort = requireChoice(args.sort, ['relevance', 'date'], 'sort', 'relevance');\n        const tag = args.major ? 'Majr' : 'MeSH Terms';\n        const esearch = await eutilsFetch('esearch', {\n            term: `${term}[${tag}]`,\n            retmax: limit,\n            usehistory: 'y',\n            sort: sort === 'date' ? 'pub_date' : '',\n        }, { label: 'pubmed mesh' });\n        const pmids = esearch?.esearchresult?.idlist;\n        if (!Array.isArray(pmids)) {\n            throw new CommandExecutionError('pubmed mesh did not return an id list', 'PubMed ESearch response shape may have changed.');\n        }\n        if (pmids.length === 0) {\n            throw new EmptyResultError('pubmed mesh', `No articles found for MeSH term \"${term}\".`);\n        }\n        return fetchSummaryRows(pmids, 'pubmed mesh summary');\n    },\n});\n","sourceCodeStart":25,"sourceCodeEnd":48,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/pubmed/mesh.js#L25-L48","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the exact MeSH heading via the NCBI MeSH Browser and use it verbatim (including commas/qualifiers like '[MeSH Terms]')","Use a broader parent heading (e.g. 'Neoplasms' instead of a very specific subtype)","Fall back to a plain pubmed search with the term as free text","Retry a differently-cased/normalized term (e.g. 'COVID-19', 'SARS-CoV-2')"],"exampleFix":"// before\nclis.pubmedMesh({ term: 'heart attack' });\n// after\nclis.pubmedMesh({ term: 'Myocardial Infarction' });","handlingStrategy":"fallback","validationCode":"// Pre-flight: confirm the MeSH heading exists and has hits\nconst probe = await eutilsFetch('esearch', { term: `${term}[MeSH Terms]`, retmax: 0 }, { label: 'probe' });\nif (Number(probe?.esearchresult?.count ?? 0) === 0) console.warn(`No articles for MeSH term \"${term}\"`);","typeGuard":null,"tryCatchPattern":"try {\n  return await clis.pubmedMesh({ term, limit });\n} catch (e) {\n  if (e.name === 'EmptyResultError' && e.scope === 'pubmed mesh') {\n    return clis.pubmedSearch({ query: term }); // fall back to free-text search\n  }\n  throw e;\n}","preventionTips":["Verify exact MeSH headings (including commas and qualifiers) via the MeSH Browser","Prefer broader parent headings for niche topics","Fall back to free-text search when MeSH vocabulary is uncertain","Treat empty results as data, not failures, in dashboards/reports"],"tags":["empty-result","search","pubmed","mesh"],"backgroundTag":"empty-search-result","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}