{"record":{"id":"e05e62352ecf8ec8","repo":"jackwener/OpenCLI","slug":"pubmed-clinical-trial","errorCode":null,"errorMessage":"pubmed clinical-trial","messagePattern":"pubmed clinical-trial","errorType":"exception","errorClass":"EmptyResultError","httpStatus":null,"severity":"info","filePath":"clis/pubmed/clinical-trial.js","lineNumber":55,"sourceCode":"        const searchQuery = buildSearchQuery(query, {\n            yearFrom,\n            yearTo,\n            articleType: 'Clinical Trial',\n            hasFullText: args['free-full-text'],\n            humanOnly: true,\n        });\n        const esearch = await eutilsFetch('esearch', {\n            term: searchQuery,\n            retmax: limit,\n            usehistory: 'y',\n            sort: sort === 'date' ? 'pub_date' : '',\n        }, { label: 'pubmed clinical-trial' });\n        const pmids = esearch?.esearchresult?.idlist;\n        if (!Array.isArray(pmids)) {\n            throw new CommandExecutionError('pubmed clinical-trial did not return an id list', 'PubMed ESearch response shape may have changed.');\n        }\n        if (pmids.length === 0) {\n            throw new EmptyResultError('pubmed clinical-trial', `No clinical trial articles matched \"${query}\".`);\n        }\n        return fetchSummaryRows(pmids, 'pubmed clinical-trial summary');\n    },\n});\n","sourceCodeStart":37,"sourceCodeEnd":60,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/pubmed/clinical-trial.js#L37-L60","documentation":"EmptyResultError('pubmed clinical-trial') thrown at clis/pubmed/clinical-trial.js:55 when ESearch returned a valid idlist array with zero entries — no PubMed clinical-trial articles match the query. This is the expected 'no hits' signal: the API worked, the search simply matched nothing.","triggerScenarios":"esearchresult.idlist is an array of length 0 because: (a) the query terms are too narrow (rare condition + restrictive date/field filters), (b) misspelled drug/condition terms, (c) sort=pub_date combined with filters that exclude everything, (d) the query uses field tags that don't apply to clinical-trial publication types.","commonSituations":"Searching an investigational drug with no published trial results; quoting the whole query so it becomes an exact phrase; adding [title] field filters that miss abstract-only records; expecting trial registry entries (ClinicalTrials.gov) that PubMed does not index.","solutions":["Broaden the query: drop quotes, field tags, and secondary filters; search just the drug or condition name","Check spelling and use MeSH terms (e.g. \"Diabetes Mellitus, Type 2\"[MeSH]) instead of free text","Remove the date/sort restrictions and re-run, then narrow incrementally","Verify in the PubMed web UI that the same query returns hits; if not, adjust the term construction in the CLI args","If you need trial registries rather than publications, query ClinicalTrials.gov API instead"],"exampleFix":"// before\nawait runCli('pubmed clinical-trial \"\\\"novel compound XYZ-42\\\"\"', { 'year-from': 2025, sort: 'date' });\n// after\nawait runCli('pubmed clinical-trial \"XYZ-42\"', {}); // broaden first, then add filters back gradually","handlingStrategy":"try-catch","validationCode":"// broad pre-check: confirm the primary term has any PubMed hits before narrowing\nconst probe = await runCli('pubmed esearch', { term: primaryTerm, retmax: 1 });\nif (!probe || probe.length === 0) console.warn(`No PubMed hits at all for \"${primaryTerm}\" — broaden the query`);","typeGuard":null,"tryCatchPattern":"try {\n  const rows = await runCli('pubmed clinical-trial', { query });\n} catch (e) {\n  if (e instanceof EmptyResultError || /No clinical trial articles matched/.test(e.message)) {\n    console.warn(`No clinical-trial hits for \"${query}\" — broaden terms or use MeSH headings.`);\n    return [];\n  }\n  throw e;\n}","preventionTips":["Start broad (single drug/condition keyword), then layer filters","Use MeSH terms and correct spelling for drug/disease names","Don't expect ClinicalTrials.gov registry records — PubMed indexes publications only","Verify query hit counts in the PubMed web UI before automating narrow searches"],"tags":["api","pubmed","empty-result","search"],"backgroundTag":"empty-result","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}