{"record":{"id":"012ff470231046cb","repo":"jackwener/OpenCLI","slug":"invalid-linux-do-topic-id-string-kwargs-id","errorCode":null,"errorMessage":"Invalid linux.do topic id: ${String(kwargs.id ?? '')}","messagePattern":"Invalid linux\\.do topic id: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"warning","filePath":"clis/linux-do/topic-content.js","lineNumber":139,"sourceCode":"    return result.data;\n}\ncli({\n    site: 'linux-do',\n    name: 'topic-content',\n    access: 'read',\n    description: 'Get the main topic body as Markdown',\n    domain: LINUX_DO_DOMAIN,\n    strategy: Strategy.COOKIE,\n    browser: true,\n    defaultFormat: 'plain',\n    args: [\n        { name: 'id', positional: true, type: 'int', required: true, help: 'Topic ID' },\n    ],\n    columns: ['content'],\n    func: async (page, kwargs) => {\n        const id = Number(kwargs.id);\n        if (!Number.isInteger(id) || id <= 0) {\n            throw new CommandExecutionError(`Invalid linux.do topic id: ${String(kwargs.id ?? '')}`);\n        }\n        const payload = await fetchTopicPayload(page, id);\n        return [extractTopicContent(payload, id)];\n    },\n});\nexport const __test__ = {\n    buildTopicMarkdownDocument,\n    extractTopicContent,\n    normalizeTopicPayload,\n};\n","sourceCodeStart":121,"sourceCodeEnd":150,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/linux-do/topic-content.js#L121-L150","documentation":"The topic-content command declares id as a required int positional. Before fetching, the func coerces kwargs.id via Number and requires a positive integer; otherwise it throws CommandExecutionError with the raw value. This validates input before hitting the network.","triggerScenarios":"Running the command with a missing, non-numeric, zero, negative, or float id — e.g. `topic-content abc`, `topic-content`, `topic-content 0`, or a URL slug pasted instead of the numeric ID.","commonSituations":"Pasting the full topic URL (e.g. https://linux.do/t/slug/12345) instead of extracting 12345; shell variable empty in a script; leading/trailing whitespace.","solutions":["Pass the numeric topic ID only: `topic-content 12345`.","Extract the ID from a pasted URL (the trailing number in /t/<slug>/<id>).","Quote the ID in scripts to avoid shell mangling.","Trim/validate the input before invoking the CLI."],"exampleFix":"// before\ncli --site linux-do --name topic-content \"https://linux.do/t/some-slug/12345\"\n// after\ncli --site linux-do --name topic-content 12345","handlingStrategy":"validation","validationCode":"const id = Number(url.match(/\\/t\\/[^/]+\\/(\\d+)/)?.[1] ?? process.argv[2]);\nif (!Number.isInteger(id) || id <= 0) {\n  throw new Error(`Invalid topic id: ${process.argv[2]}`);\n}","typeGuard":"const isValidTopicId = (v) => Number.isInteger(Number(v)) && Number(v) > 0;","tryCatchPattern":"try {\n  return await cliRun(['topic-content', String(id)]);\n} catch (e) {\n  if (/Invalid linux\\.do topic id/.test(e?.message ?? '')) {\n    console.error('Pass the numeric topic ID, not a URL or slug.');\n  } else throw e;\n}","preventionTips":["Extract numeric IDs from topic URLs before invoking","Validate ID inputs in wrapper scripts","Quote positional args in shell scripts"],"tags":["cli","argument-validation","input-validation"],"backgroundTag":"invalid-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}