{"record":{"id":"3b41aa90bc66f50b","repo":"jackwener/OpenCLI","slug":"cannot-resolve-aid-for-bvid-bvid-3b41aa","errorCode":null,"errorMessage":"Cannot resolve aid for bvid: ${bvid}","messagePattern":"Cannot resolve aid for bvid: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/bilibili/comments.js","lineNumber":138,"sourceCode":"        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            })\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}`);","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/bilibili/comments.js#L120-L156","documentation":"Thrown when the /x/web-interface/view API succeeded (code 0) but its data contains no aid — the numeric article/video ID that the reply endpoints require as oid. The BV ID alone cannot query replies, so the bvid→aid mapping failed and the command cannot proceed.","triggerScenarios":"Calling bilibili comments with a resolvable bvid whose view payload lacks aid — e.g. deleted/hidden videos, non-video content (bangumi, courses) that uses a different ID scheme, or API responses omitting aid.","commonSituations":"Video taken down or region-locked after ID resolution; passing a BV ID from a bangumi episode or a seasonal content page; schema change in the view endpoint.","solutions":["Verify the video is still available and is a regular video (open the URL in a browser)","Use the BV ID of the actual video content, not a bangumi/seasonal page","Check login/cookies if the video is age- or region-restricted and the view API truncates data","Update the library if Bilibili moved the aid field in the view response"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function hasAid(viewData) {\n    return !!viewData && Number.isInteger(viewData.aid) && viewData.aid > 0;\n}","tryCatchPattern":"try {\n    const rows = await bilibiliComments(bvid);\n} catch (err) {\n    if (/Cannot resolve aid/.test(err.message)) {\n        // confirm the video exists/is a regular video, then retry or skip\n    } else throw err;\n}","preventionTips":["Verify the video loads in a browser before scripting against it","Use BV IDs of regular videos, not bangumi/seasonal pages","Keep cookies valid for restricted videos so the view API returns full data","Check video availability in bulk jobs and skip unavailable items"],"tags":["bilibili","id-resolution","api"],"backgroundTag":"id-resolution-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}