jackwener/OpenCLI · error · CommandExecutionError

Bilibili conclusion API returned malformed data

Error message

Bilibili conclusion API returned malformed data

What it means

readModelResult() inspects the `data` object returned by the conclusion endpoint (already unwrapped by requireOkPayload). If data is missing or not a plain object, it throws this CommandExecutionError: the endpoint answered successfully at the envelope level but the nested data needed to find the AI summary is absent or the wrong shape, so parsing cannot continue.

Source

Thrown at clis/bilibili/summary.js:74

}

function requireOkPayload(payload, label) {
    if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {
        throw new CommandExecutionError(`Bilibili ${label} API returned a malformed payload`);
    }
    if (payload.code !== 0) {
        const message = payload.message ?? 'unknown error';
        if (payload.code === -101 || payload.code === -403 || /登录|权限|forbidden|permission|login/i.test(String(message))) {
            throw new AuthRequiredError('bilibili.com', `Bilibili ${label} API requires login or permission: ${message} (${payload.code})`);
        }
        throw new CommandExecutionError(`Bilibili ${label} API failed: ${message} (${payload.code})`);
    }
    return payload.data;
}

function readModelResult(data, bvid) {
    if (!data || typeof data !== 'object' || Array.isArray(data)) {
        throw new CommandExecutionError('Bilibili conclusion API returned malformed data');
    }
    if (data.code !== 0) {
        throw new EmptyResultError('bilibili summary', `Bilibili has not generated an AI summary for ${bvid}.`);
    }
    let modelResult = data.model_result;
    if (typeof modelResult === 'string') {
        try {
            modelResult = JSON.parse(modelResult);
        } catch {
            throw new CommandExecutionError('Bilibili conclusion API returned malformed model_result JSON');
        }
    }
    if (!modelResult || typeof modelResult !== 'object' || Array.isArray(modelResult)) {
        throw new CommandExecutionError('Bilibili conclusion API returned malformed model_result');
    }
    const summary = String(modelResult.summary ?? '').trim();
    if (!summary) {
        throw new EmptyResultError('bilibili summary', `Bilibili has not generated an AI summary for ${bvid}.`);

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Retry with a different video to confirm whether the endpoint ever returns data for your session.
  2. Log the raw conclusion response to inspect what shape data actually has.
  3. Update/patch the CLI's response parsing if Bilibili changed the contract.
  4. Treat it like the missing-summary case: verify in a browser whether the video has an AI summary at all.

Example fix

// before
const model = readModelResult(payload.data, bvid); // data may be undefined
// after
if (!payload.data || typeof payload.data !== 'object') {
  throw new Error(`conclusion data missing: ${JSON.stringify(payload).slice(0, 200)}`);
}
const model = readModelResult(payload.data, bvid);
Defensive patterns

Strategy: type-guard

Type guard

function hasConclusionData(payload) {
  const d = payload?.data;
  return d !== null && typeof d === 'object' && !Array.isArray(d);
}

Try / catch

try {
  const model = await summaryCommand(bvid);
} catch (e) {
  if (/conclusion API returned malformed data/.test(e.message)) {
    // endpoint returned code:0 with no data — likely no summary support for this video
    return null;
  }
  throw e;
}

Prevention

When it happens

Trigger: The conclusion API returns `{ code: 0 }` with no `data` field (observed on videos with no AI summary in some API states), or data is a string/array/null due to an API format change; readModelResult is called by command() after conclusionData().

Common situations: Bilibili silently changed the response contract for videos lacking summaries; a proxy/cache stripped the data field; older CLI version parsing a newer/older API shape.

Understand the failure class

Related errors


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