{"record":{"id":"2571b24007b2e4bb","repo":"jackwener/OpenCLI","slug":"bilibili-pinned-comments-bvid","errorCode":null,"errorMessage":"bilibili pinned comments: ${bvid}","messagePattern":"bilibili pinned comments: (.+?)","errorType":"exception","errorClass":"EmptyResultError","httpStatus":null,"severity":"warning","filePath":"clis/bilibili/comments.js","lineNumber":154,"sourceCode":"        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            })\n            : await apiGet(page, '/x/v2/reply/main', {\n                params: { oid: aid, type: 1, mode: 3, ps: top ? 1 : limit },\n                signed: true,\n            });\n        const label = parent != null ? 'reply thread' : 'reply main';\n        const data = requireOkPayload(payload, label);\n        const replies = top\n            ? requireTopReplies(data, label)\n            : requireReplies(data, label);\n        if (replies.length === 0) {\n            if (top) {\n                throw new EmptyResultError(`bilibili pinned comments: ${bvid}`);\n            }\n            throw new EmptyResultError(parent != null ? `bilibili comment replies: ${parent}` : `bilibili comments: ${bvid}`);\n        }\n        return replies.slice(0, limit).map(formatReplyRow);\n    },\n});\n","sourceCodeStart":136,"sourceCodeEnd":161,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/bilibili/comments.js#L136-L161","documentation":"An EmptyResultError thrown when --top was requested but the reply-main API returned an empty top_replies array — the video has no pinned comment, so there is nothing to show.","triggerScenarios":"Running 'bilibili comments <bvid> --top' on a video where the uploader/moderator has not pinned any comment (top_replies: [] after requireTopReplies).","commonSituations":"Most videos simply have no pinned comment; scripting a batch over videos assuming each has one; checking a freshly uploaded video before the author pinned anything.","solutions":["Run without --top to list normal comments instead","Handle EmptyResultError as a benign 'no pinned comment' outcome in scripts","Pick a different video if the pinned comment specifically is required"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    const pinned = await bilibiliComments(bvid, { top: true });\n} catch (err) {\n    if (err instanceof EmptyResultError || /pinned comments/.test(err.message)) {\n        const all = await bilibiliComments(bvid); // fall back to normal comments\n    } else throw err;\n}","preventionTips":["Treat EmptyResultError for --top as expected for most videos","Fall back to normal comments when no pin exists","Avoid assuming every video has a pinned comment in batch jobs","Check a video's page in the browser to confirm a pin exists first"],"tags":["bilibili","empty-result","pinned-comments"],"backgroundTag":"empty-result-set","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}