{"record":{"id":"cae2885d6fcf67dd","repo":"jackwener/OpenCLI","slug":"stackoverflow-related-id-must-be-a-numeric-questio","errorCode":null,"errorMessage":"stackoverflow related id must be a numeric question id, got ${JSON.stringify(args.id)}","messagePattern":"stackoverflow related id must be a numeric question id, got (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/stackoverflow/related.js","lineNumber":36,"sourceCode":"\ncli({\n    site: 'stackoverflow',\n    name: 'related',\n    access: 'read',\n    description: 'List Stack Overflow questions related to a given question id.',\n    domain: 'stackoverflow.com',\n    strategy: Strategy.PUBLIC,\n    browser: false,\n    args: [\n        { name: 'id', positional: true, required: true, type: 'string', help: 'Stack Overflow question id (numeric, e.g. 79935770).' },\n        { name: 'sort', type: 'string', default: 'rank', help: `Sort key: ${SORT_OPTIONS.join(', ')} (rank = SO relevance default).` },\n        { name: 'limit', type: 'int', default: 20, help: 'Max related questions (1-100).' },\n    ],\n    columns: ['rank', 'id', 'title', 'score', 'answers', 'views', 'isAnswered', 'tags', 'author', 'createdAt', 'lastActivityAt', 'url'],\n    func: async (args) => {\n        const id = String(args.id ?? '').trim();\n        if (!/^\\d+$/.test(id)) {\n            throw new ArgumentError(`stackoverflow related id must be a numeric question id, got ${JSON.stringify(args.id)}`);\n        }\n        const sort = String(args.sort ?? 'rank').toLowerCase();\n        if (!SORT_OPTIONS.includes(sort)) {\n            throw new ArgumentError(`stackoverflow related sort must be one of ${SORT_OPTIONS.join(', ')}`);\n        }\n        const limit = normalizeLimit(args.limit, 20, 100, 'limit');\n        const data = await seFetch(`/questions/${encodeURIComponent(id)}/related`, {\n            searchParams: {\n                order: 'desc',\n                sort,\n                pagesize: limit,\n            },\n        });\n        const items = ensureItems(data, `stackoverflow related ${id}`);\n        return items.slice(0, limit).map((q, i) => ({\n            rank: i + 1,\n            id: q.question_id,\n            title: decodeHtmlEntities(q.title || ''),","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/stackoverflow/related.js#L18-L54","documentation":"ArgumentError from `stackoverflow related` when the positional `id` argument fails the /^\\d+$/ numeric check. The command requires a bare numeric Stack Overflow question id because it is interpolated into the /questions/{id}/related API path. Any non-numeric or empty value is rejected before any network request is made.","triggerScenarios":"`stackoverflow related` with an empty id, a question URL pasted whole (https://stackoverflow.com/questions/123/...), an id containing letters or symbols, or a slug like 'how-do-i-x'.","commonSituations":"Pasting a full SO URL instead of just the numeric id; forgetting the positional argument entirely; scripts passing 'undefined'/'null' from an upstream variable; using an answer id or user id rather than a question id.","solutions":["Pass only the numeric question id, e.g. `stackoverflow related 79935770`.","If you have a full URL, extract the digits first: url.match(/\\/questions\\/(\\d+)/)?.[1].","Confirm you are using a question id (from /questions/...), not an answer or comment id.","In scripts, validate the id with /^\\d+$/ before invoking the command."],"exampleFix":"// before\nstackoverflow related \"https://stackoverflow.com/questions/79935770/why-x\"\n// after\nstackoverflow related 79935770","handlingStrategy":"validation","validationCode":"const id = String(rawId ?? '').trim();\nif (!/^\\d+$/.test(id)) throw new TypeError(`expected numeric SO question id, got ${JSON.stringify(rawId)}`);","typeGuard":"function isQuestionId(v) { return typeof v === 'string' && /^\\d+$/.test(v.trim()); }","tryCatchPattern":"try {\n  await related(id);\n} catch (e) {\n  if (e.name === 'ArgumentError' && e.message.includes('numeric question id')) {\n    const m = String(id).match(/\\/(?:questions|q)\\/(\\d+)/);\n    if (m) return related(m[1]);\n  }\n  throw e;\n}","preventionTips":["Strip ids out of pasted URLs before invoking: url.match(/\\/questions\\/(\\d+)/)[1].","Never pass whole URLs, slugs, or answer ids as the id argument.","Validate with /^\\d+$/ in wrapper scripts before calling the CLI."],"tags":["argument-validation","cli","input-validation"],"backgroundTag":"invalid-argument-format","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}