{"record":{"id":"0ad45524d276008f","repo":"jackwener/OpenCLI","slug":"invalid-novel-id-id","errorCode":null,"errorMessage":"Invalid novel ID: ${id}","messagePattern":"Invalid novel ID: (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/pixiv/novel-download.js","lineNumber":25,"sourceCode":"  name: 'novel-download',\n  access: 'read',\n  description: 'Download Pixiv novel text as txt or markdown',\n  domain: 'www.pixiv.net',\n  strategy: Strategy.COOKIE,\n  args: [\n    { name: 'novel-id', positional: true, required: true, help: 'Novel ID' },\n    { name: 'output', default: './pixiv-downloads/novels', help: 'Output directory' },\n    { name: 'file-format', default: 'txt', help: 'Output file format: txt or md' },\n    { name: 'execute', type: 'boolean', default: false, help: 'Actually write the local novel file' },\n  ],\n  columns: ['novel_id', 'title', 'format', 'status', 'path'],\n  func: async (page, kwargs) => {\n    if (kwargs.execute !== true) {\n      throw new ArgumentError('Refusing to write a local Pixiv novel: pass --execute');\n    }\n    const id = String(kwargs['novel-id'] ?? '');\n    if (!/^\\d+$/.test(id)) {\n      throw new ArgumentError(`Invalid novel ID: ${id}`, 'Example: opencli pixiv novel-download 10588915 --file-format txt');\n    }\n    const format = normalizeNovelFileFormat(kwargs['file-format'] ?? kwargs.format);\n    const output = normalizePixivOutputRoot(kwargs.output, './pixiv-downloads/novels');\n    const body = await fetchNovelForDownload(page, id);\n    const destPath = writeNovelFile(body, output, format);\n    return [{ novel_id: body.id, title: body.title, format, status: 'success', path: destPath }];\n  },\n});\n","sourceCodeStart":7,"sourceCodeEnd":34,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/pixiv/novel-download.js#L7-L34","documentation":"Before fetching, the command validates the novel ID against /^\\d+$/ (digits only). Pixiv novel IDs are positive integers; anything else (letters, whitespace, hyphens, empty string, undefined coerced to '') throws ArgumentError. The second ArgumentError argument carries a usage hint with a valid example.","triggerScenarios":"Passing `--novel-id` with a non-numeric value (e.g. 'abc', '10588915a', ' 123'), omitting --novel-id entirely (id becomes ''), or a URL pasted instead of the raw ID.","commonSituations":"Pasting a full Pixiv novel URL like https://www.pixiv.net/novel/show.php?id=10588915 instead of just the number; shell variables that are empty or unset; typos or trailing punctuation copied from a page.","solutions":["Pass only the numeric ID: `opencli pixiv novel-download 10588915 --execute --file-format txt`.","If using a URL, extract the id query parameter first, e.g. `url.split('id=')[1]` or a shell regex.","Check the variable feeding --novel-id is set and contains only digits (trim whitespace)."],"exampleFix":"// before\nconst id = 'https://www.pixiv.net/novel/show.php?id=10588915';\nawait cli.pixivNovelDownload({ 'novel-id': id });\n// after\nconst id = new URL(url).searchParams.get('id'); // '10588915'\nif (!/^\\d+$/.test(id)) throw new Error('novel-id must be numeric');\nawait cli.pixivNovelDownload({ 'novel-id': id });","handlingStrategy":"validation","validationCode":"const raw = String(args['novel-id'] ?? '').trim();\nconst id = raw.includes('id=') ? new URL(raw).searchParams.get('id') : raw;\nif (!/^\\d+$/.test(id)) {\n  throw new Error(`Invalid novel ID: ${id} — use digits only, e.g. 10588915`);\n}","typeGuard":"function isPixivNovelId(v) {\n  return typeof v === 'string' && /^\\d+$/.test(v.trim());\n}","tryCatchPattern":"try {\n  await cli.pixiv.novelDownload({ 'novel-id': id, execute: true });\n} catch (e) {\n  if (e instanceof ArgumentError && /Invalid novel ID/.test(e.message)) {\n    console.error(`Bad novel ID '${id}': use only digits, e.g. 10588915`);\n  } else throw e;\n}","preventionTips":["Extract the numeric ID from URLs instead of pasting whole URLs.","Trim and validate shell variables feeding --novel-id before invoking.","Reject empty/undefined values early with a clear CLI usage message."],"tags":["cli","argument-error","input-validation"],"backgroundTag":"invalid-argument-format","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}