{"record":{"id":"ba4f6efee2781d8d","repo":"jackwener/OpenCLI","slug":"invalid-illustration-id-id","errorCode":null,"errorMessage":"Invalid illustration ID: ${id}","messagePattern":"Invalid illustration ID: (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"warning","filePath":"clis/pixiv/detail.js","lineNumber":45,"sourceCode":"        { name: 'id', required: true, positional: true, help: 'Illustration ID' },\n    ],\n    columns: [\n        'illust_id',\n        'title',\n        'author',\n        'type',\n        'pages',\n        'bookmarks',\n        'likes',\n        'views',\n        'tags',\n        'created',\n        'url',\n    ],\n    func: async (page, kwargs) => {\n        const id = String(kwargs.id ?? '');\n        if (!/^\\d+$/.test(id)) {\n            throw new ArgumentError(`Invalid illustration ID: ${id}`, 'Example: opencli pixiv detail 123456');\n        }\n        const body = await pixivFetch(page, `/ajax/illust/${id}`, {\n            notFoundMsg: `Illustration not found: ${id}`,\n        });\n        const b = requireIllustBody(body, id);\n        return [{\n            illust_id: b.illustId,\n            title: b.illustTitle,\n            author: b.userName,\n            user_id: b.userId,\n            type: b.illustType === 0 ? 'illust' : b.illustType === 1 ? 'manga' : b.illustType === 2 ? 'ugoira' : String(b.illustType),\n            pages: b.pageCount,\n            bookmarks: b.bookmarkCount,\n            likes: b.likeCount,\n            views: b.viewCount,\n            tags: (b.tags?.tags || []).map(t => t.tag).join(', '),\n            created: b.createDate?.split('T')[0] || '',\n            url: `https://www.pixiv.net/artworks/${b.illustId}`,","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/pixiv/detail.js#L27-L63","documentation":"The pixiv detail command reads kwargs.id, coerces it to a string, and requires it to be purely digits before constructing the /ajax/illust/<id> URL. This ArgumentError is thrown before any network request when the supplied ID is empty, contains non-numeric characters (URLs, \"artwork123\", whitespace), or is missing entirely.","triggerScenarios":"Running `opencli pixiv detail` with no id; passing a full Pixiv URL like https://www.pixiv.net/artworks/123456; passing \"12345678_1\" (page suffix) or a non-numeric slug; passing a novel ID format the regex rejects.","commonSituations":"User pastes the whole artwork URL instead of the numeric ID; shell quoting strips input leaving an empty string; copy includes trailing punctuation or a page suffix like `_2`; confusion between illust IDs and user IDs.","solutions":["Pass only the numeric artwork ID, e.g. `opencli pixiv detail 123456`.","Extract the number from a pasted URL first (the digits after /artworks/ or ?illust_id=).","Strip non-digit suffixes like page indicators (`_1`) or whitespace before invoking.","If programmatically calling, validate with /^\\d+$/.test(String(id)) before invoking the command.","Use the example from the error message: `opencli pixiv detail 123456`."],"exampleFix":"// before\nopencli pixiv detail https://www.pixiv.net/artworks/987654\n// after\nopencli pixiv detail 987654","handlingStrategy":"validation","validationCode":"function normalizeIllustId(raw) {\n  const m = String(raw ?? '').match(/(\\d+)(?:_\\d+)?$/); // accepts URLs, page suffixes\n  const id = m ? m[1] : String(raw ?? '').trim();\n  if (!/^\\d+$/.test(id)) throw new Error(`Invalid illustration ID: ${raw}`);\n  return id;\n}\nawait cliDetail(page, { id: normalizeIllustId(input) });","typeGuard":"function isIllustId(v) {\n  return typeof v === 'string' && /^\\d+$/.test(v);\n}","tryCatchPattern":"try {\n  const rows = await pixivDetail(page, { id });\n} catch (e) {\n  if (e instanceof ArgumentError && e.message.startsWith('Invalid illustration ID')) {\n    console.error('Provide a numeric Pixiv artwork ID, e.g. opencli pixiv detail 123456');\n    process.exitCode = 2;\n  } else throw e;\n}","preventionTips":["Always pass bare numeric IDs, never full URLs or IDs with _page suffixes.","Extract digits from pasted URLs (/artworks/(\\d+) or ?illust_id=).","Validate with /^\\d+$/ before invoking the command programmatically.","Trim whitespace/quotes from shell arguments; empty strings also fail."],"tags":["pixiv","argument-validation","cli-input","invalid-id"],"backgroundTag":"invalid-input-format","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}