jackwener/OpenCLI · error · CommandExecutionError

Bilibili ${label} API did not return replies

Error message

Bilibili ${label} API did not return replies

What it means

CommandExecutionError thrown by requireReplies when the successful reply payload's data object has no `replies` property at all. Bilibili normally includes `replies` (possibly null when there are no comments), so a missing key means an unexpected response shape.

Source

Thrown at clis/bilibili/comments.js:55

    if (!payload || typeof payload !== 'object' || Array.isArray(payload) || !Object.hasOwn(payload, 'code')) {
        throw new CommandExecutionError(`Bilibili ${label} API returned a malformed payload`);
    }
    if (payload.code !== 0) {
        const message = payload.message ?? 'unknown error';
        if (isAuthLikeBilibiliError(payload.code, 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 requireReplies(data, label) {
    if (!data || typeof data !== 'object' || Array.isArray(data)) {
        throw new CommandExecutionError(`Bilibili ${label} API returned malformed data`);
    }
    if (!Object.hasOwn(data, 'replies')) {
        throw new CommandExecutionError(`Bilibili ${label} API did not return replies`);
    }
    if (data.replies === null) {
        return [];
    }
    if (!Array.isArray(data.replies)) {
        throw new CommandExecutionError(`Bilibili ${label} API returned malformed replies`);
    }
    return data.replies;
}

function requireTopReplies(data, label) {
    if (!data || typeof data !== 'object' || Array.isArray(data)) {
        throw new CommandExecutionError(`Bilibili ${label} API returned malformed data`);
    }
    if (!Object.hasOwn(data, 'top_replies')) {
        throw new CommandExecutionError(`Bilibili ${label} API did not return top_replies`);
    }
    if (!Array.isArray(data.top_replies)) {

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Retry; check for videos with zero comments (should yield replies: null, not a missing key — if you see this consistently, the shape changed)
  2. Update the CLI library to a version matching the current Bilibili API
  3. Capture the raw response for a bug report

Example fix

null
Defensive patterns

Strategy: retry

Validate before calling

null

Type guard

function hasReplies(d) { return !!d && typeof d === 'object' && !Array.isArray(d) && Object.hasOwn(d, 'replies'); }

Try / catch

try { const rows = await run(['bilibili','comments',bvid]); } catch (e) { if (/did not return replies/.test(e.message)) return retryWithBackoff(fn, 2); throw e; }

Prevention

When it happens

Trigger: API code===0 but data lacks `replies` — e.g. the reply/main endpoint returned a cursor/object of a different shape, or a degraded/risk-control response.

Common situations: Bilibili A/B-testing new response formats; interception by anti-bot returning success with truncated data; using a stale library against a changed API.

Related errors


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