{"record":{"id":"19e143c06c812dd7","repo":"jackwener/OpenCLI","slug":"arxiv-author-cannot-be-empty","errorCode":null,"errorMessage":"arxiv author cannot be empty","messagePattern":"arxiv author cannot be empty","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/arxiv/author.js","lineNumber":25,"sourceCode":"import { ArgumentError, EmptyResultError } from '@jackwener/opencli/errors';\nimport { arxivFetch, normalizeArxivLimit, parseEntries } from './utils.js';\n\ncli({\n    site: 'arxiv',\n    name: 'author',\n    access: 'read',\n    description: 'List arXiv papers by a given author (newest first)',\n    strategy: Strategy.PUBLIC,\n    browser: false,\n    args: [\n        { name: 'author', positional: true, required: true, help: 'Author name (e.g. \"Yoshua Bengio\" or \"Y Bengio\")' },\n        { name: 'limit', type: 'int', default: 20, help: 'Max papers to return (max 50)' },\n    ],\n    columns: ['id', 'title', 'authors', 'published', 'primary_category', 'url'],\n    func: async (args) => {\n        const authorText = String(args.author || '').trim();\n        if (!authorText) {\n            throw new ArgumentError('arxiv author cannot be empty', 'Example: opencli arxiv author \"Yoshua Bengio\"');\n        }\n        const limit = normalizeArxivLimit(args.limit, 20, 50);\n        // Quote the value so multi-word author names match as a phrase.\n        const query = encodeURIComponent(`au:\"${authorText}\"`);\n        const xml = await arxivFetch(`search_query=${query}&max_results=${limit}&sortBy=submittedDate&sortOrder=descending`);\n        const entries = parseEntries(xml);\n        if (!entries.length) {\n            throw new EmptyResultError('arxiv author', `No papers found for author \"${authorText}\". Try alternate spellings (e.g. initials).`);\n        }\n        return entries.map(e => ({\n            id: e.id,\n            title: e.title,\n            authors: e.authors,\n            published: e.published,\n            primary_category: e.primary_category,\n            url: e.url,\n        }));\n    },","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/arxiv/author.js#L7-L43","documentation":"An ArgumentError thrown before any network call when the `author` argument to `arxiv author` is missing, empty, or whitespace-only. The library validates input early so users get a precise message (with an example) instead of a confusing empty-result or API error from arXiv. It is pure input validation — nothing was sent to arXiv.","triggerScenarios":"Running `opencli arxiv author` with no argument, `--author \"\"`, or `--author \"   \"`; quoting mistakes in the shell that drop the argument entirely.","commonSituations":"Shell quoting errors (unescaped spaces collapsing args); scripting with a variable that is empty because an upstream lookup failed; forgetting the positional argument.","solutions":["Pass the author name in quotes: opencli arxiv author \"Yoshua Bengio\"","Check the shell command for quoting/escaping mistakes that swallowed the argument","If driven by a script/variable, verify the variable is non-empty before invoking","Use the documented example format shown in the error hint"],"exampleFix":"// before\nrun(`opencli arxiv author ${name}`); // name may be empty\n// after\nif (!name?.trim()) throw new Error('author name is required');\nrun(`opencli arxiv author \"${name.trim()}\"`);","handlingStrategy":"validation","validationCode":"const author = String(process.argv[2] || '').trim();\nif (!author) throw new Error('Usage: opencli arxiv author \"<author name>\"');","typeGuard":"function hasAuthorName(a) { return typeof a === 'string' && a.trim().length > 0; }","tryCatchPattern":"try {\n  await exec('opencli arxiv author ' + JSON.stringify(author));\n} catch (e) {\n  if (e.message.includes('author cannot be empty')) {\n    console.error('Provide a quoted author name, e.g. opencli arxiv author \"Yoshua Bengio\"');\n    process.exitCode = 1;\n    return;\n  }\n  throw e;\n}","preventionTips":["Always quote author names in the shell","Trim and check arguments before invoking CLI commands","Default missing args to an interactive prompt in wrapper scripts","Validate upstream variables that feed the argument"],"tags":["validation","input","arxiv","cli"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}