{"record":{"id":"f88771f805c9a4fe","repo":"jackwener/OpenCLI","slug":"bilibili-comments-top-cannot-be-combined-with","errorCode":null,"errorMessage":"bilibili comments --top cannot be combined with --parent (pinned comments only exist at the top level)","messagePattern":"bilibili comments --top cannot be combined with --parent \\(pinned comments only exist at the top level\\)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/bilibili/comments.js","lineNumber":124,"sourceCode":"    description: '获取 B站视频评论（官方 API；用 --parent <rpid> 读取某条评论下的「楼中楼」回复；用 --top 只看置顶评论）',\n    domain: 'www.bilibili.com',\n    strategy: Strategy.COOKIE,\n    args: [\n        { name: 'bvid', required: true, positional: true, help: 'Video BV ID (e.g. BV1WtAGzYEBm)' },\n        { name: 'parent', type: 'int', help: 'rpid of a comment — fetch the replies under it instead of top-level comments' },\n        { name: 'top', type: 'boolean', default: false, help: '只返回置顶评论（与 --parent 互斥）' },\n        { name: 'limit', type: 'int', default: 20, help: 'Number of comments (max 50)' },\n    ],\n    columns: ['rank', 'rpid', 'author', 'text', 'likes', 'replies', 'time'],\n    func: async (page, kwargs) => {\n        if (!page) {\n            throw new CommandExecutionError('Browser session required for bilibili comments');\n        }\n        const limit = parseLimit(kwargs.limit);\n        const parent = parseParent(kwargs.parent);\n        const top = kwargs.top === true;\n        if (top && parent != null) {\n            throw new ArgumentError('bilibili comments --top cannot be combined with --parent (pinned comments only exist at the top level)');\n        }\n        let bvid;\n        try {\n            bvid = await resolveBvid(kwargs.bvid);\n        }\n        catch (error) {\n            throw new ArgumentError(`Cannot resolve Bilibili BV ID from input: ${String(kwargs.bvid ?? '')}`, error instanceof Error ? error.message : String(error));\n        }\n        // Resolve bvid → aid (required by reply API)\n        const view = await apiGet(page, '/x/web-interface/view', { params: { bvid } });\n        const viewData = requireOkPayload(view, 'view');\n        const aid = viewData?.aid;\n        if (!aid)\n            throw new CommandExecutionError(`Cannot resolve aid for bvid: ${bvid}`);\n        const payload = parent != null\n            ? await apiGet(page, '/x/v2/reply/reply', {\n                params: { oid: aid, type: 1, root: parent, pn: 1, ps: limit },\n            })","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/bilibili/comments.js#L106-L142","documentation":"An ArgumentError raised when both --top and --parent are passed to bilibili comments. Pinned comments only exist at the top level of a video's comment section, so a nested reply-thread query (--parent) cannot also be filtered to pinned comments; the flags are mutually exclusive by design.","triggerScenarios":"Running 'bilibili comments <bvid> --top --parent <rpid>' — top is true and parent is a non-null integer.","commonSituations":"Scripted invocations that always append --top; users assuming --top filters pinned comments inside a sub-thread; copy-pasted flag combos.","solutions":["Remove --top when querying replies under a parent rpid","Remove --parent when you want only pinned top-level comments","In scripts, build flags conditionally: pass --top or --parent, never both"],"exampleFix":"// before\nawait run(['bilibili', 'comments', bvid, '--top', '--parent', rpid]);\n// after\nawait run(['bilibili', 'comments', bvid, '--parent', rpid]); // or drop --parent to use --top","handlingStrategy":"validation","validationCode":"if (args.includes('--top') && (args.includes('--parent') || parent != null)) {\n    throw new Error('--top and --parent are mutually exclusive');\n}","typeGuard":"function isFlagComboValid(kwargs) {\n    return !(kwargs.top === true && kwargs.parent != null);\n}","tryCatchPattern":"try {\n    const rows = await bilibiliComments(bvid, { top, parent });\n} catch (err) {\n    if (err instanceof ArgumentError && /--top cannot be combined/.test(err.message)) {\n        // drop one flag and retry\n    } else throw err;\n}","preventionTips":["Build CLI flags conditionally in scripts — top XOR parent","Validate argparse inputs before dispatch","Remember pinned comments exist only at the top level","Document the exclusivity in any wrapper you write"],"tags":["cli-usage","argument-error","mutually-exclusive-flags"],"backgroundTag":"mutually-exclusive-flags","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}