jackwener/OpenCLI · error · CommandExecutionError
Bilibili creator comparison API returned malformed list data
Error message
Bilibili creator comparison API returned malformed list data
What it means
After the envelope's `code` passes (code === 0), requirePayload additionally requires payload.data to be a record containing an array `list`. If code is 0 but data/list is missing or of the wrong type, the response is considered contract-violating and this CommandExecutionError is thrown. This guards against success-shaped responses whose payload structure changed.
Source
Thrown at clis/bilibili/creator-stats.js:60
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 AuthRequiredError
|| error instanceof EmptyResultError
|| error instanceof CommandExecutionError
|| error instanceof TimeoutErrorView on GitHub (pinned to 49907e53dc)
Solutions
- Log a sample of the raw payload (when code === 0) to see the new shape and update requirePayload's whitelist (payload.data.list) accordingly
- Check whether the account has any manuscripts/analytics; try with an account that has published videos
- Pin/retest against the sanitized creator-center probe fixtures to detect a schema drift
- If Bilibili migrated the endpoint, find the new field name or endpoint and update the CLI
Defensive patterns
Strategy: validation
Validate before calling
function hasListShape(payload) {
return payload?.code === 0 && payload.data && !Array.isArray(payload.data) && Array.isArray(payload.data.list);
}
// call the endpoint once with a probe account and assert hasListShape before production use Type guard
function hasValidListData(payload) {
return Boolean(payload?.data) && typeof payload.data === 'object' && !Array.isArray(payload.data) && Array.isArray(payload.data.list);
} Try / catch
try {
const rows = await runCommand();
} catch (e) {
if (/malformed list data/.test(e.message)) {
// capture raw payload for diagnosis; check account has manuscripts / schema drift
} else throw e;
} Prevention
- Test with an account that has published manuscripts and generated analytics
- Keep probe fixtures refreshed against the live undocumented endpoint
- Alert on schema drift: log raw payloads when code === 0 but data.list is absent
- Track Bilibili creator-center API changes in a changelog
When it happens
Trigger: Endpoint returns {code: 0, data: null}, {code: 0, data: {}}, or {code: 0, data: {list: {...}}} — e.g. Bilibili renamed `list`, moved it, or returns no data for accounts with zero analyzable manuscripts.
Common situations: Bilibili silently changing the undocumented response schema; brand-new creator accounts with no rows returning an empty/non-list data; probe fixtures drifting from production behavior.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Bilibili creator comparison API returned a malformed envelop
- Bilibili creator comparison returned a malformed manuscript
- Bilibili creator comparison returned duplicate rows for ${bv
- Bilibili conclusion API returned malformed data
- Bilibili conclusion API returned malformed model_result
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/7120eec2c763bcdb.
Report an issue: GitHub.