{"record":{"id":"516e9d8d958b95c4","repo":"jackwener/OpenCLI","slug":"bilibili-creator-center-login-is-required-messa","errorCode":null,"errorMessage":"Bilibili creator-center login is required: ${message}","messagePattern":"Bilibili creator-center login is required: (.+?)","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/bilibili/creator-stats.js","lineNumber":55,"sourceCode":"\nfunction isRecord(value) {\n    return Boolean(value) && typeof value === 'object' && !Array.isArray(value);\n}\n\nfunction isAuthLike(code, message) {\n    return code === -101\n        || code === -111\n        || /登录|账号未登录|login required|not logged in/i.test(String(message ?? ''));\n}\n\nfunction requirePayload(payload) {\n    if (!isRecord(payload) || !Number.isSafeInteger(payload.code)) {\n        throw new CommandExecutionError('Bilibili creator comparison API returned a malformed envelope');\n    }\n    const message = String(payload.message ?? payload.msg ?? 'unknown error');\n    if (payload.code !== 0) {\n        if (isAuthLike(payload.code, message)) {\n            throw new AuthRequiredError('member.bilibili.com', `Bilibili creator-center login is required: ${message}`);\n        }\n        throw new CommandExecutionError(`Bilibili creator comparison API failed: ${message} (${payload.code})`);\n    }\n    if (!isRecord(payload.data) || !Array.isArray(payload.data.list)) {\n        throw new CommandExecutionError('Bilibili creator comparison API returned malformed list data');\n    }\n    return payload.data.list;\n}\n\nasync function fetchComparison(page) {\n    try {\n        const payload = await page.fetchJson(\n            `${MEMBER_ORIGIN}/x/web/data/archive_diagnose/compare?size=100`,\n            { timeoutMs: FETCH_TIMEOUT_SECONDS * 1000 },\n        );\n        return requirePayload(payload);\n    }\n    catch (error) {","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/bilibili/creator-stats.js#L37-L73","documentation":"When the comparison endpoint returns a well-formed envelope whose `code` is non-zero and isAuthLike() matches (code -101/-111, or a message containing 登录/账号未登录/login required/not logged in), the library rethrows the condition as AuthRequiredError for member.bilibili.com. This distinguishes 'you are not logged in' from a generic API failure so callers can trigger an interactive login flow.","triggerScenarios":"fetchJson on the archive_diagnose/compare endpoint returns {code: -101 or -111, message/msg containing 登录 or 'not logged in'} — i.e. the cookie session is missing, expired, or lacks creator-center scope.","commonSituations":"Browser cookies expired since last login; user logged out of bilibili.com; session cookie not carried into the CLI's Strategy.COOKIE browser profile; account restricted so the creator center demands re-authentication.","solutions":["Open member.bilibili.com/platform/home in the CLI's browser profile and log in / re-login to refresh the session cookie","Clear bilibili.com cookies and log in again to obtain a fresh SESSDATA","Confirm the logged-in account actually owns creator-center data (the endpoint requires an authenticated creator account)","Complete any security verification (captcha/SMS) Bilibili prompts before retrying"],"exampleFix":"// before\n$ opencli bilibili creator-stats BV1xx411c7mD\nAuthRequiredError: Bilibili creator-center login is required: 账号未登录\n\n// after: re-authenticate in the shared browser profile\n$ # log into member.bilibili.com in the browser, then retry:\n$ opencli bilibili creator-stats BV1xx411c7mD","handlingStrategy":"try-catch","validationCode":"const probe = await fetch('https://member.bilibili.com/x/web/data/archive_diagnose/compare?size=1', { headers: { cookie } });\nconst body = await probe.json();\nif (body?.code === -101 || body?.code === -111 || /登录|not logged in/i.test(body?.message ?? body?.msg ?? '')) {\n  throw new Error('Refresh your member.bilibili.com login first');\n}","typeGuard":null,"tryCatchPattern":"try {\n  const rows = await runCommand();\n} catch (e) {\n  if (e.name === 'AuthRequiredError') {\n    // open member.bilibili.com/platform/home for an interactive login, then retry\n  } else throw e;\n}","preventionTips":["Re-login to bilibili.com periodically; SESSDATA cookies expire","Verify the CLI's browser profile persists cookies (not ephemeral incognito storage)","Confirm the logged-in account is a creator with analytics access","Catch AuthRequiredError explicitly and drive an interactive login flow"],"tags":["bilibili","authentication","session-expired","cookie"],"backgroundTag":"auth-login-required","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}