jackwener/OpenCLI · error · CommandExecutionError
Bilibili creator comparison API failed: ${message} (${payloa
Error message
Bilibili creator comparison API failed: ${message} (${payload.code}) What it means
Generic failure branch of requirePayload: the envelope is well formed but `code` is a non-zero value that is not auth-like. The Bilibili message (payload.message/msg) and numeric code are surfaced verbatim in a CommandExecutionError. Because this endpoint is undocumented, arbitrary negative Bilibili codes (rate-limit, permission, internal) land here.
Source
Thrown at clis/bilibili/creator-stats.js:57
return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
}
function isAuthLike(code, message) {
return code === -101
|| code === -111
|| /登录|账号未登录|login required|not logged in/i.test(String(message ?? ''));
}
function requirePayload(payload) {
if (!isRecord(payload) || !Number.isSafeInteger(payload.code)) {
throw new CommandExecutionError('Bilibili creator comparison API returned a malformed envelope');
}
const message = String(payload.message ?? payload.msg ?? 'unknown error');
if (payload.code !== 0) {
if (isAuthLike(payload.code, message)) {
throw new AuthRequiredError('member.bilibili.com', `Bilibili creator-center login is required: ${message}`);
}
throw new CommandExecutionError(`Bilibili creator comparison API failed: ${message} (${payload.code})`);
}
if (!isRecord(payload.data) || !Array.isArray(payload.data.list)) {
throw new CommandExecutionError('Bilibili creator comparison API returned malformed list data');
}
return payload.data.list;
}
async function fetchComparison(page) {
try {
const payload = await page.fetchJson(
`${MEMBER_ORIGIN}/x/web/data/archive_diagnose/compare?size=100`,
{ timeoutMs: FETCH_TIMEOUT_SECONDS * 1000 },
);
return requirePayload(payload);
}
catch (error) {
if (
error instanceof AuthRequiredErrorView on GitHub (pinned to 49907e53dc)
Solutions
- Read the numeric code and Chinese message in the error to identify the Bilibili business error and act on it (e.g. -412 → slow down / wait, then retry)
- Retry after a backoff if the code indicates rate limiting or a transient server error
- Verify the account still has creator-center access for the requested analytics
- If the code persists, check whether Bilibili changed/retired the undocumented compare endpoint
Defensive patterns
Strategy: retry
Try / catch
try {
const rows = await runCommand();
} catch (e) {
const m = /\((\-?\d+)\)$/.exec(e.message);
const code = m ? Number(m[1]) : null;
if (code === -412) { /* rate limited: back off exponentially and retry */ }
else if (code === -403) { /* permission: check account scope */ }
else throw e;
} Prevention
- Space out requests to Bilibili's creator-center endpoints to avoid -412 risk control
- Parse the numeric code from the '(code)' suffix for targeted handling
- Monitor Bilibili API status; transient 5xx-style codes clear on retry
- Keep the account in good standing with creator-center access
When it happens
Trigger: fetchJson on archive_diagnose/compare returns e.g. {code: -412, message: '请求被拦截'} or {code: -403, ...} — any business error other than -101/-111 or login-text messages.
Common situations: Bilibili rate-limiting or risk-control blocking the request (-412); account lacking permission for the analytics scope; transient Bilibili server errors (-500); endpoint deprecated or moved on the server side.
Related errors
- Bilibili view API failed: ${payload.message} (${payload.code
- 获取视频分P信息失败: ${payload?.message ?? 'unknown'} (${payload?.cod
- 获取关注列表失败: ${payload.message} (${payload.code})
- Bilibili relation query returned a malformed attribute
- [风控拦截/未登录] 获取到的 subtitle_url 为空!请确保 CLI 已成功登录且风控未封锁此账号。
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/370481059f7663ae.
Report an issue: GitHub.