{"record":{"id":"ee7e0546e73f7f2d","repo":"jackwener/OpenCLI","slug":"pubmed-article","errorCode":null,"errorMessage":"pubmed article","messagePattern":"pubmed article","errorType":"exception","errorClass":"EmptyResultError","httpStatus":null,"severity":"error","filePath":"clis/pubmed/article.js","lineNumber":28,"sourceCode":"    description: 'Get detailed information for a PubMed article by PMID',\n    domain: 'pubmed.ncbi.nlm.nih.gov',\n    strategy: Strategy.PUBLIC,\n    browser: false,\n    defaultFormat: 'plain',\n    args: [\n        { name: 'pmid', positional: true, required: true, help: 'PubMed ID, e.g. 37780221' },\n        { name: 'full-abstract', type: 'boolean', default: false, help: 'Do not truncate the abstract in table output' },\n    ],\n    columns: ['pmid', 'title', 'authors', 'journal', 'year', 'date', 'article_type', 'language', 'doi', 'pmc', 'affiliations', 'grants', 'mesh_terms', 'keywords', 'abstract', 'url'],\n    func: async (args) => {\n        const pmid = requirePmid(args.pmid);\n        const xml = await eutilsFetch('efetch', {\n            id: pmid,\n            rettype: 'abstract',\n        }, { retmode: 'xml', label: 'pubmed article' });\n        const article = parseArticleXml(xml, pmid);\n        if (!article) {\n            throw new EmptyResultError('pubmed article', `No article found for PMID ${pmid}.`);\n        }\n        if (!article.title) {\n            throw new CommandExecutionError(`pubmed article ${pmid} did not include a title`, 'PubMed EFetch response shape may have changed.');\n        }\n        const abstract = args['full-abstract'] ? article.abstract : truncateText(article.abstract, 500);\n        return [\n            {\n                pmid: article.pmid,\n                title: article.title,\n                authors: article.authors.join(', '),\n                journal: article.journal,\n                year: article.year,\n                date: article.date || null,\n                article_type: article.article_type,\n                language: article.language || null,\n                doi: article.doi || null,\n                pmc: article.pmc || null,\n                affiliations: article.affiliations || null,","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/pubmed/article.js#L10-L46","documentation":"EmptyResultError('pubmed article') thrown at clis/pubmed/article.js:28 when eutilsFetch('efetch') succeeded but parseArticleXml returned null/undefined for the requested PMID. The CLI treats this as 'no data' rather than a crash: the XML came back but contained no parseable article matching the PMID.","triggerScenarios":"parseArticleXml(xml, pmid) returns falsy because: (a) the PMID does not exist or was withdrawn/removed from PubMed, (b) EFetch returned an error XML (e.g. <eFetchResult> with no <PubmedArticle>) for an invalid id, (c) the rettype 'abstract' XML has a shape parseArticleXml does not recognize.","commonSituations":"Passing a DOI instead of a PMID; a typo'd or stale PMID from an old reference list; querying a book/in-process record whose XML differs; NCBI returns an error document for an id that was suppressed.","solutions":["Verify the PMID exists by opening https://pubmed.ncbi.nlm.nih.gov/<pmid>/ in a browser","Check the raw EFetch response (add debug logging on xml) to see if NCBI returned an error or empty document","If you have a DOI or other id, resolve it to a PMID first via esearch before calling efetch","Validate the PMID input (digits only) before calling the command","Retry later if NCBI is having a transient issue; confirm status at the NCBI status page"],"exampleFix":"// before\nconst article = parseArticleXml(xml, pmid);\nif (!article) {\n    throw new EmptyResultError('pubmed article', `No article found for PMID ${pmid}.`);\n}\n// after\nif (!/^\\d+$/.test(pmid)) {\n    throw new ArgumentError(`\"${pmid}\" is not a valid PMID (expected numeric id)`);\n}\nconst article = parseArticleXml(xml, pmid);\nif (!article) {\n    throw new EmptyResultError('pubmed article', `No article found for PMID ${pmid}.`);\n}","handlingStrategy":"validation","validationCode":"// validate the PMID before calling the command\nif (!/^\\d{1,9}$/.test(pmid)) {\n  throw new Error(`\"${pmid}\" is not a numeric PMID`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  const article = await runCli('pubmed article', { pmid });\n} catch (e) {\n  if (e instanceof EmptyResultError || /No article found/.test(e.message)) {\n    console.warn(`PMID ${pmid} not found in PubMed — verify the id.`);\n    return null;\n  }\n  throw e;\n}","preventionTips":["Only pass numeric PMIDs (resolve DOIs via esearch first)","Spot-check unknown PMIDs on the PubMed website before batch runs","Log raw efetch XML when debugging to spot error documents","Keep a list of withdrawn/suppressed PMIDs if reusing old datasets"],"tags":["api","pubmed","empty-result","input-validation"],"backgroundTag":"empty-result","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}