{"record":{"id":"0e61dc9d1f3f0ee7","repo":"jackwener/OpenCLI","slug":"answer-id-must-be-a-numeric-id-a-zhihu-answer-url-0e61dc","errorCode":null,"errorMessage":"Answer ID must be a numeric id, a Zhihu answer URL, or answer:<qid>:<aid>","messagePattern":"Answer ID must be a numeric id, a Zhihu answer URL, or answer:<qid>:<aid>","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/zhihu/answer-detail.js","lineNumber":41,"sourceCode":"    }\n}\n\ncli({\n    site: 'zhihu',\n    name: 'answer-detail',\n    access: 'read',\n    description: '知乎单个回答完整内容（按 answer ID 获取）',\n    domain: 'www.zhihu.com',\n    strategy: Strategy.COOKIE,\n    args: [\n        { name: 'id', required: true, positional: true, help: 'Answer ID, full Zhihu answer URL, or typed target (answer:<qid>:<aid>)' },\n        { name: 'max-content', type: 'int', default: 0, help: 'Optional cap on stripped content length in characters (0 = no truncation, return the full answer)' },\n    ],\n    columns: ['id', 'author', 'votes', 'comments', 'question_id', 'question_title', 'url', 'created_at', 'updated_at', 'content'],\n    func: async (page, kwargs) => {\n        const target = parseAnswerTarget(kwargs.id);\n        if (!target) {\n            throw new ArgumentError(\n                'Answer ID must be a numeric id, a Zhihu answer URL, or answer:<qid>:<aid>',\n                'Example: opencli zhihu answer-detail 1937205528846655537',\n            );\n        }\n        const { answerId } = target;\n        // `--max-content 0` (the default) means \"no cap, return the\n        // full stripped answer\". Any positive value is an opt-in user\n        // cap, mirroring the wikipedia `page` pattern — we never\n        // silently truncate behind the user's back.\n        const rawMaxContent = kwargs['max-content'];\n        const maxContent = rawMaxContent == null ? 0 : Number(rawMaxContent);\n        if (!Number.isInteger(maxContent) || maxContent < 0) {\n            throw new ArgumentError(\n                '--max-content must be a non-negative integer (0 = no cap, full content)',\n                'Example: --max-content 2000',\n            );\n        }\n        // Navigate to the answer page itself: this both seeds the","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/zhihu/answer-detail.js#L23-L59","documentation":"answer-detail uses the same parseAnswerTarget validation as answer-comments: the id argument must be a numeric answer id, a Zhihu answer URL, or answer:<qid>:<aid>, otherwise this ArgumentError is thrown with a usage example. It is thrown before any browser navigation.","triggerScenarios":"Passing a question id, an article (zhuanlan.zhihu.com) URL, a missing or empty id, or a malformed answer: prefix string to zhihu answer-detail.","commonSituations":"Mixing up question vs answer ids; pasting a pinned-comment or share link that isn't an /answer/ URL; whitespace or invisible characters in a copy-pasted id.","solutions":["Pass a numeric answer id: opencli zhihu answer-detail 1937205528846655537","Or pass the full answer URL containing /answer/<aid>","Or use answer:<qid>:<aid> form","Trim whitespace and strip URL fragments/query params before passing"],"exampleFix":"// before\nopencli zhihu answer-detail https://zhuanlan.zhihu.com/p/999\n// after\nopencli zhihu answer-detail https://www.zhihu.com/question/123/answer/1937205528846655537","handlingStrategy":"validation","validationCode":"const m = String(id).match(/answer\\/(\\d+)/) || String(id).match(/^answer:(\\d+):(\\d+)$/) || (/^\\d+$/.test(String(id).trim()) ? [null, String(id).trim()] : null);\nif (!m) throw new Error('answer-detail needs a numeric id, answer URL, or answer:<qid>:<aid>');","typeGuard":"const isAnswerDetailTarget = (v) => typeof v === 'string' && (/^\\d+$/.test(v.trim()) || /\\/answer\\/\\d+/.test(v) || /^answer:\\d+:\\d+$/.test(v.trim()));","tryCatchPattern":null,"preventionTips":["Don't pass question or zhuanlan article ids to answer-detail","Normalize share links to canonical /answer/ URLs first","Keep a small parser/mapper for Zhihu URLs in your scripts"],"tags":["zhihu","argument-validation","cli-input"],"backgroundTag":"invalid-argument-format","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}