{"record":{"id":"0858f347f2b416a0","repo":"jackwener/OpenCLI","slug":"hf-paper-id-cannot-be-empty","errorCode":null,"errorMessage":"hf paper id cannot be empty","messagePattern":"hf paper id cannot be empty","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/hf/paper.js","lineNumber":24,"sourceCode":"\nconst ARXIV_ID_PATTERN = /^\\d{4}\\.\\d{4,5}(?:v\\d+)?$/;\n\ncli({\n    site: 'hf',\n    name: 'paper',\n    access: 'read',\n    description: 'Hugging Face paper detail by arXiv id (full title / summary / authors / AI keywords)',\n    domain: 'huggingface.co',\n    strategy: Strategy.PUBLIC,\n    browser: false,\n    args: [\n        { name: 'id', positional: true, required: true, help: 'arXiv id (e.g. \"1706.03762\") — same value HF uses to mirror the paper' },\n    ],\n    columns: ['id', 'title', 'authors', 'publishedAt', 'upvotes', 'aiKeywords', 'summary', 'aiSummary', 'url'],\n    func: async (args) => {\n        const raw = String(args.id ?? '').trim();\n        if (!raw) {\n            throw new ArgumentError('hf paper id cannot be empty', 'Example: opencli hf paper 1706.03762');\n        }\n        if (!ARXIV_ID_PATTERN.test(raw)) {\n            throw new ArgumentError(\n                `hf paper id \"${args.id}\" is not a valid arXiv id`,\n                'Expected the modern arXiv form `YYMM.NNNNN` (optionally with a version suffix like `v3`).',\n            );\n        }\n        const endpoint = process.env.HF_ENDPOINT?.replace(/\\/+$/, '') || 'https://huggingface.co';\n        const url = `${endpoint}/api/papers/${encodeURIComponent(raw)}`;\n        let resp;\n        try {\n            resp = await fetch(url, { headers: { accept: 'application/json' } });\n        }\n        catch (err) {\n            throw new CommandExecutionError(`hf paper request failed: ${err?.message ?? err}`);\n        }\n        if (resp.status === 404) {\n            throw new EmptyResultError('hf paper', `Hugging Face has no paper page for \"${raw}\".`);","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/hf/paper.js#L6-L42","documentation":"ArgumentError('hf paper id cannot be empty') thrown at clis/hf/paper.js:24 when the required positional `id` argument is missing, an empty string, or whitespace-only after trim(). The library requires an arXiv id because it fetches a single paper detail from the HF /api/papers/<id> endpoint.","triggerScenarios":"Running `opencli hf paper` with no positional argument; passing an empty string (--id '' or id=\"\"); passing only whitespace ('   '); a shell variable interpolating to empty (id=\"$PAPER_ID\" with PAPER_ID unset) so String(args.id ?? '').trim() yields ''.","commonSituations":"Forgetting the positional argument because the user expected an interactive prompt; unquoted variable expansion producing an empty argument in scripts; copy-paste losing the id; wrapper scripts not propagating arguments (missing \"$@\").","solutions":["Provide an arXiv id positionally: opencli hf paper 1706.03762.","Ensure the value is non-empty after trimming (no bare spaces).","In scripts, guard the variable: : \"${PAPER_ID:?PAPER_ID is required}\" before invoking.","Use `opencli hf paper --help` to see the required positional `id` argument."],"exampleFix":"// before\nopencli hf paper $ID            # ID unset -> empty arg\n// after\nopencli hf paper \"${ID:?arXiv id required}\"","handlingStrategy":"validation","validationCode":"function validatePaperId(raw) {\n  const id = String(raw ?? '').trim();\n  if (!id) throw new Error('arXiv id is required, e.g. 1706.03762');\n  return id;\n}\n// shell: : \"${PAPER_ID:?PAPER_ID is required}\"","typeGuard":"const hasPaperId = (v) => typeof v === 'string' && v.trim().length > 0;","tryCatchPattern":"try {\n  await run(`hf paper ${id}`);\n} catch (e) {\n  if (String(e.message).includes('id cannot be empty')) {\n    console.error('Usage: opencli hf paper <arxiv-id>  e.g. opencli hf paper 1706.03762');\n  } else throw e;\n}","preventionTips":["Always quote positional args: opencli hf paper \"$ID\".","Default-check shell variables with ${ID:?msg} before invoking.","Never rely on prompts — the id is a required positional argument.","Trim user-supplied input before passing it through."],"tags":["argument-validation","cli","missing-argument","huggingface"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}