jackwener/OpenCLI · error · CommandExecutionError

Bilibili view API did not return cid/up_mid for ${bvid}

Error message

Bilibili view API did not return cid/up_mid for ${bvid}

What it means

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.

Source

Thrown at clis/bilibili/summary.js:150

    access: 'read',
    description: '获取 B站视频的官方 AI 总结(视频页「AI总结」同款,含分段大纲与时间戳)',
    domain: 'www.bilibili.com',
    strategy: Strategy.COOKIE,
    args: [
        { name: 'bvid', required: true, positional: true, help: 'Video BV ID / URL / b23.tv short link' },
    ],
    columns: ['time', 'content'],
    func: async (page, kwargs) => {
        if (!page) {
            throw new CommandExecutionError('Browser session required for bilibili summary');
        }
        const bvid = await readBvid(kwargs.bvid);
        const view = await apiGet(page, '/x/web-interface/view', { params: { bvid } });
        const viewData = requireOkPayload(view, 'view');
        const cid = viewData?.cid;
        const upMid = viewData?.owner?.mid;
        if (!cid || !upMid) {
            throw new CommandExecutionError(`Bilibili view API did not return cid/up_mid for ${bvid}`);
        }
        const conclusion = await apiGet(page, '/x/web-interface/view/conclusion/get', {
            params: { bvid, cid, up_mid: upMid },
            signed: true,
        });
        const conclusionData = requireOkPayload(conclusion, 'conclusion');
        return rowsFromModel(readModelResult(conclusionData, bvid));
    },
});

export const __test__ = {
    command,
    formatTime,
    readBvid,
    readModelResult,
    rowsFromModel,
};

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Verify the bvid resolves to a live video on bilibili.com — deleted videos lack cid/owner.
  2. Log requireOkPayload's returned viewData to inspect which field is missing.
  3. Retry in a logged-in session with valid cookies — degraded anti-bot payloads often omit fields.
  4. Resolve b23.tv short links to their final bvid before calling, and confirm the redirect target is valid.
  5. Check for region restrictions or try from a different network if the payload looks stubbed.

Example fix

// before
const cid = viewData?.cid;
const upMid = viewData?.owner?.mid;
if (!cid || !upMid) {
    throw new CommandExecutionError(`Bilibili view API did not return cid/up_mid for ${bvid}`);
}
// after
const cid = viewData?.cid;
const upMid = viewData?.owner?.mid;
if (!cid || !upMid) {
    console.error('viewData:', JSON.stringify(viewData));
    return null; // video likely unavailable or region-locked
}
Defensive patterns

Strategy: validation

Validate before calling

const viewData = requireOkPayload(view, 'view');
if (!viewData?.cid || !viewData?.owner?.mid) {
  console.warn(`view payload lacks cid/owner.mid for ${bvid}; video may be unavailable`);
}

Type guard

function hasViewIdentifiers(vd) {
  return !!vd && typeof vd.cid === 'number' && typeof vd?.owner?.mid === 'number';
}

Try / catch

try {
  const model = await readModelResult(page, bvid);
} catch (e) {
  if (String(e.message).includes('did not return cid/up_mid')) {
    console.warn(`Video ${bvid} unavailable or region-locked; skipping`);
    return null;
  }
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Missing required field" and "field is required" errors: why libraries reject payloads that omit mandatory fields — this error's family across 20 libraries.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/979f2be3543e4a98. Report an issue: GitHub.