{"record":{"id":"979f2be3543e4a98","repo":"jackwener/OpenCLI","slug":"bilibili-view-api-did-not-return-cid-up-mid-for","errorCode":null,"errorMessage":"Bilibili view API did not return cid/up_mid for ${bvid}","messagePattern":"Bilibili view API did not return cid/up_mid for (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/bilibili/summary.js","lineNumber":150,"sourceCode":"    access: 'read',\n    description: '获取 B站视频的官方 AI 总结（视频页「AI总结」同款，含分段大纲与时间戳）',\n    domain: 'www.bilibili.com',\n    strategy: Strategy.COOKIE,\n    args: [\n        { name: 'bvid', required: true, positional: true, help: 'Video BV ID / URL / b23.tv short link' },\n    ],\n    columns: ['time', 'content'],\n    func: async (page, kwargs) => {\n        if (!page) {\n            throw new CommandExecutionError('Browser session required for bilibili summary');\n        }\n        const bvid = await readBvid(kwargs.bvid);\n        const view = await apiGet(page, '/x/web-interface/view', { params: { bvid } });\n        const viewData = requireOkPayload(view, 'view');\n        const cid = viewData?.cid;\n        const upMid = viewData?.owner?.mid;\n        if (!cid || !upMid) {\n            throw new CommandExecutionError(`Bilibili view API did not return cid/up_mid for ${bvid}`);\n        }\n        const conclusion = await apiGet(page, '/x/web-interface/view/conclusion/get', {\n            params: { bvid, cid, up_mid: upMid },\n            signed: true,\n        });\n        const conclusionData = requireOkPayload(conclusion, 'conclusion');\n        return rowsFromModel(readModelResult(conclusionData, bvid));\n    },\n});\n\nexport const __test__ = {\n    command,\n    formatTime,\n    readBvid,\n    readModelResult,\n    rowsFromModel,\n};\n","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/bilibili/summary.js#L132-L168","documentation":"After fetching the view payload, the command extracts cid and owner.mid (up_mid), both required as parameters for the signed conclusion/get call. If either is missing, this CommandExecutionError is thrown because the AI-conclusion endpoint cannot be queried without them.","triggerScenarios":"The /x/web-interface/view response has code 0 but its data lacks cid or owner.mid — e.g. a deleted/审核-blocked video, region-locked content returning a stub payload, or an anti-bot degraded response.","commonSituations":"Requesting summaries for removed or private videos; bvid resolved from a b23.tv short link pointing to a now-deleted video; hitting the API from an IP/region where the view payload is minimized.","solutions":["Verify the bvid resolves to a live video on bilibili.com — deleted videos lack cid/owner.","Log requireOkPayload's returned viewData to inspect which field is missing.","Retry in a logged-in session with valid cookies — degraded anti-bot payloads often omit fields.","Resolve b23.tv short links to their final bvid before calling, and confirm the redirect target is valid.","Check for region restrictions or try from a different network if the payload looks stubbed."],"exampleFix":"// before\nconst cid = viewData?.cid;\nconst upMid = viewData?.owner?.mid;\nif (!cid || !upMid) {\n    throw new CommandExecutionError(`Bilibili view API did not return cid/up_mid for ${bvid}`);\n}\n// after\nconst cid = viewData?.cid;\nconst upMid = viewData?.owner?.mid;\nif (!cid || !upMid) {\n    console.error('viewData:', JSON.stringify(viewData));\n    return null; // video likely unavailable or region-locked\n}","handlingStrategy":"validation","validationCode":"const viewData = requireOkPayload(view, 'view');\nif (!viewData?.cid || !viewData?.owner?.mid) {\n  console.warn(`view payload lacks cid/owner.mid for ${bvid}; video may be unavailable`);\n}","typeGuard":"function hasViewIdentifiers(vd) {\n  return !!vd && typeof vd.cid === 'number' && typeof vd?.owner?.mid === 'number';\n}","tryCatchPattern":"try {\n  const model = await readModelResult(page, bvid);\n} catch (e) {\n  if (String(e.message).includes('did not return cid/up_mid')) {\n    console.warn(`Video ${bvid} unavailable or region-locked; skipping`);\n    return null;\n  }\n  throw e;\n}","preventionTips":["Verify the bvid points to a live public video before querying","Resolve b23.tv short links to final bvids first","Retry with a logged-in session if payloads look degraded/stubbed","Log the full view payload when diagnosing missing fields"],"tags":["bilibili","api-response","missing-field","video-availability"],"backgroundTag":"missing-required-field","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}