{"record":{"id":"3173b0995c614384","repo":"jackwener/OpenCLI","slug":"invalid-stack-overflow-question-id-args-id","errorCode":null,"errorMessage":"Invalid Stack Overflow question id: ${args.id}","messagePattern":"Invalid Stack Overflow question id: (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/stackoverflow/read.js","lineNumber":228,"sourceCode":"cli({\n    site: 'stackoverflow',\n    name: 'read',\n    access: 'read',\n    description: 'Read a Stack Overflow question with answers and comments',\n    domain: 'stackoverflow.com',\n    strategy: Strategy.PUBLIC,\n    browser: false,\n    args: [\n        { name: 'id', required: true, positional: true, help: 'Stack Overflow question id (numeric, e.g. 79935770)' },\n        { name: 'answers-limit', type: 'int', default: 10, help: 'Max answers to include (1-100; accepted answer always included first)' },\n        { name: 'comments-limit', type: 'int', default: 5, help: 'Max comments per question/answer (1-100)' },\n        { name: 'max-length', type: 'int', default: 4000, help: 'Max characters per body / answer / comment (min 100)' },\n    ],\n    columns: ['type', 'author', 'score', 'accepted', 'text'],\n    func: async (args) => {\n        const id = String(args.id || '').trim();\n        if (!/^\\d+$/.test(id)) {\n            throw new ArgumentError(`Invalid Stack Overflow question id: ${args.id}`, 'Pass a numeric id like 79935770');\n        }\n        const answersLimit = requireBoundedInt(args['answers-limit'] ?? 10, 1, SE_MAX_PAGE_SIZE, 'stackoverflow read --answers-limit');\n        const commentsLimit = requireBoundedInt(args['comments-limit'] ?? 5, 1, SE_MAX_PAGE_SIZE, 'stackoverflow read --comments-limit');\n        const maxLength = requireMinInt(args['max-length'] ?? 4000, 100, 'stackoverflow read --max-length');\n\n        const label = `stackoverflow/${id}`;\n        const qUrl = `${SE_API_BASE}/questions/${id}?site=${SE_SITE}&filter=withbody`;\n        const qData = await fetchJson(qUrl, label);\n        const question = (qData.items || [])[0];\n        if (!question) {\n            throw new EmptyResultError(label, 'Question not found');\n        }\n\n        // Fetch question comments and answers in parallel.\n        const [qCommentsData, answersData] = await Promise.all([\n            fetchJson(\n                `${SE_API_BASE}/questions/${id}/comments?site=${SE_SITE}&filter=withbody&order=asc&sort=creation&pagesize=${commentsLimit}`,\n                `${label}/comments`,","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/stackoverflow/read.js#L210-L246","documentation":"The read command's func throws this ArgumentError when the positional question id is not a purely numeric string (fails /^\\d+$/ after trim). Stack Exchange question ids are positive integers, so any other input is rejected up front with a hint to pass a numeric id like 79935770.","triggerScenarios":"Running `stackoverflow read` with a URL pasted instead of an id (e.g. https://stackoverflow.com/questions/79935770/...), a slug, an empty string, or a id containing letters or signs like '+79935770'.","commonSituations":"Copy-pasting the whole question URL from a browser instead of extracting the numeric path segment; shell variable interpolating empty; passing an answer id with a prefix; forgetting to quote an id containing special characters.","solutions":["Pass just the numeric id: stackoverflow read 79935770","Extract the id from a question URL — the digits after /questions/","Trim whitespace and ensure no leading + or surrounding characters reach the CLI"],"exampleFix":"// before\nstackoverflow read https://stackoverflow.com/questions/79935770/how-do-i-x\n// after\nstackoverflow read 79935770","handlingStrategy":"validation","validationCode":"const id = String(rawId || '').trim();\nif (!/^\\d+$/.test(id)) throw new Error(`Pass a numeric question id, got: ${rawId}`);","typeGuard":"function isStackOverflowQuestionId(v) {\n  return typeof v === 'string' && /^\\d+$/.test(v.trim());\n}","tryCatchPattern":"try {\n  await runCommand(['stackoverflow', 'read', id]);\n} catch (e) {\n  if (e instanceof ArgumentError && e.message.startsWith('Invalid Stack Overflow question id')) {\n    const m = /questions\\/(\\d+)/.exec(String(id));\n    if (m) return runCommand(['stackoverflow', 'read', m[1]]); // extract id from pasted URL\n    console.error('Pass a numeric id like 79935770');\n  } else throw e;\n}","preventionTips":["Extract the numeric segment from question URLs before passing them (digits after /questions/)","Validate with /^\\d+$/ in scripts before invoking","Trim whitespace and reject empty strings early","Never pass answer ids or slugs where a question id is expected"],"tags":["validation","argument-error","cli-input"],"backgroundTag":"invalid-resource-id","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}