{"record":{"id":"48308c1303ccb34d","repo":"jackwener/OpenCLI","slug":"bilibili-creator-center-login-is-required-detai","errorCode":null,"errorMessage":"Bilibili creator-center login is required: ${detail}","messagePattern":"Bilibili creator-center login is required: (.+?)","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/bilibili/creator-stats.js","lineNumber":87,"sourceCode":"            { timeoutMs: FETCH_TIMEOUT_SECONDS * 1000 },\n        );\n        return requirePayload(payload);\n    }\n    catch (error) {\n        if (\n            error instanceof AuthRequiredError\n            || error instanceof EmptyResultError\n            || error instanceof CommandExecutionError\n            || error instanceof TimeoutError\n        ) {\n            throw error;\n        }\n        const detail = `${error?.message ?? error} ${error?.hint ?? ''}`.trim();\n        if (/abort|timed?\\s*out|timeout/i.test(detail)) {\n            throw new TimeoutError('Bilibili creator comparison', FETCH_TIMEOUT_SECONDS);\n        }\n        if (/HTTP\\s+(401|403)|登录|passport|\\/login\\b/i.test(detail)) {\n            throw new AuthRequiredError('member.bilibili.com', `Bilibili creator-center login is required: ${detail}`);\n        }\n        throw new CommandExecutionError(`Bilibili creator comparison request failed: ${detail}`);\n    }\n}\n\nfunction selectTarget(list, bvid) {\n    const matches = [];\n    for (const item of list) {\n        if (!isRecord(item) || typeof item.bvid !== 'string' || !/^BV[0-9A-Za-z]{10}$/.test(item.bvid)) {\n            throw new CommandExecutionError('Bilibili creator comparison returned a malformed manuscript row');\n        }\n        if (item.bvid === bvid) matches.push(item);\n    }\n    if (matches.length > 1) {\n        throw new CommandExecutionError(`Bilibili creator comparison returned duplicate rows for ${bvid}`);\n    }\n    if (matches.length === 0) {\n        throw new EmptyResultError(","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/bilibili/creator-stats.js#L69-L105","documentation":"Second classification branch in fetchComparison's catch: if the underlying error's message/hint matches /HTTP\\s+(401|403)|登录|passport|\\/login\\b/i, the error is rethrown as AuthRequiredError('member.bilibili.com', ...). This catches HTTP-level 401/403 responses and passport/login redirects that occur before a JSON envelope exists.","triggerScenarios":"page.fetchJson receives an HTTP 401/403 from member.bilibili.com, or is redirected to passport.bilibili.com / a /login URL — session cookie absent, expired, or rejected at the HTTP layer rather than via an API code.","commonSituations":"Fully expired SESSDATA cookie causing a passport redirect; IP flagged by risk control returning 403; browser profile logged out; corporate proxy stripping cookies.","solutions":["Log in to member.bilibili.com in the browser profile the CLI uses, then re-run the command","Clear bilibili.com cookies and re-authenticate to obtain a fresh session","Check whether your IP/network is being blocked (403) and try a different network","Verify the CLI browser profile actually retains cookies (not incognito/headless with fresh storage)"],"exampleFix":"// before\n$ opencli bilibili creator-stats BV1xx411c7mD\nAuthRequiredError: Bilibili creator-center login is required: HTTP 403 ... passport.bilibili.com/login\n\n// after: re-login in the shared browser profile, then retry\n$ opencli bilibili creator-stats BV1xx411c7mD","handlingStrategy":"try-catch","validationCode":"const res = await fetch('https://member.bilibili.com/platform/home', { headers: { cookie }, redirect: 'manual' });\nif (res.status === 401 || res.status === 403 || (res.status >= 300 && /passport|login/.test(res.headers.get('location') || ''))) {\n  throw new Error('Session expired — re-login to member.bilibili.com first');\n}","typeGuard":null,"tryCatchPattern":"try {\n  const rows = await runCommand();\n} catch (e) {\n  if (e.name === 'AuthRequiredError') {\n    // launch interactive login to member.bilibili.com, then retry once\n  } else throw e;\n}","preventionTips":["Pre-flight check for 401/403 or passport redirects before running the command","Keep SESSDATA fresh; re-login before cookie expiry","Avoid networks/IPs flagged by Bilibili risk control (403)","Handle AuthRequiredError as a first-class flow: authenticate then retry"],"tags":["bilibili","authentication","http-403","session-expired"],"backgroundTag":"auth-login-required","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}