{"record":{"id":"87e227b36321312b","repo":"DIYgod/RSSHub","slug":"uid-bilibili-cookie-87e227","errorCode":null,"errorMessage":"缺少对应 uid 的 Bilibili 用户登录后的 Cookie 值","messagePattern":"缺少对应 uid 的 Bilibili 用户登录后的 Cookie 值","errorType":"exception","errorClass":"ConfigNotFoundError","httpStatus":503,"severity":"error","filePath":"lib/routes/bilibili/message-unread.ts","lineNumber":82,"sourceCode":"    data: {\n        unfollow_unread: number;\n        follow_unread: number;\n        unfollow_push_msg: number;\n        dustbin_push_msg: number;\n        dustbin_unread: number;\n        biz_msg_unfollow_unread: number;\n        biz_msg_follow_unread: number;\n        custom_unread: number;\n    };\n}\n\nasync function handler(ctx) {\n    const uid = ctx.req.param('uid');\n    const name = await cache.getUsernameFromUID(uid);\n\n    const cookie = config.bilibili.cookies[uid];\n    if (cookie === undefined) {\n        throw new ConfigNotFoundError('缺少对应 uid 的 Bilibili 用户登录后的 Cookie 值');\n    }\n\n    // Fetch message unread counts\n    const [msgUnread, sessionUnread] = await Promise.all([\n        ofetch<UnreadMsgResponse>('https://api.vc.bilibili.com/x/im/web/msgfeed/unread', {\n            query: {\n                build: 0,\n                mobi_app: 'web',\n            },\n            headers: {\n                Referer: 'https://message.bilibili.com/',\n                Cookie: cookie,\n            },\n        }),\n        ofetch<UnreadSessionResponse>('https://api.vc.bilibili.com/session_svr/v1/session_svr/single_unread', {\n            query: {\n                unread_type: 0,\n                show_dustbin: 1,","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/bilibili/message-unread.ts#L64-L100","documentation":"ConfigNotFoundError thrown by /bilibili/message/unread/:uid (unread-count summary). The handler calls two endpoints (msgfeed/unread and session_svr/single_unread) in parallel via Promise.all, both requiring the per-uid Cookie; if config.bilibili.cookies[uid] is undefined the route aborts up front with the dedicated subclass.","triggerScenarios":"Requesting /bilibili/message/unread/:uid when BILIBILI_COOKIE_{uid} for that uid is not set in the RSSHub environment.","commonSituations":"Operator added a cookie for the like/reply feeds but not for the same uid here; URL uid differs from configured uid; env var not exported into the container.","solutions":["Set BILIBILI_COOKIE_{uid} (matching the URL uid) to the full logged-in bilibili.com Cookie; restart RSSHub.","Verify the variable is loaded (config.bilibili.cookies keys or `env | grep BILIBILI_COOKIE_`).","Ensure URL uid and env var suffix match exactly."],"exampleFix":"// before: /bilibili/message/unread/2267573 with no env -> ConfigNotFoundError\n\n// after:\n//   BILIBILI_COOKIE_2267573=SESSDATA=...; bili_jct=...; DedeUserID=2267573; ...","handlingStrategy":"validation","validationCode":"import { config } from '@/config';\nfunction requireUnreadCookie(uid: string) {\n  if (config.bilibili.cookies[uid] === undefined) {\n    throw new Error(`Set BILIBILI_COOKIE_${uid} for /bilibili/message/unread/${uid}`);\n  }\n}\nrequireUnreadCookie('2267573');","typeGuard":"function isConfigNotFoundError(e: unknown): e is Error {\n  return e instanceof Error && e.name === 'ConfigNotFoundError';\n}","tryCatchPattern":"try { await unreadHandler(ctx); }\ncatch (e) {\n  if (e instanceof Error && e.name === 'ConfigNotFoundError') {\n    ctx.status = 503; ctx.body = { error: 'Missing BILIBILI_COOKIE_' + uid }; return;\n  }\n  throw e;\n}","preventionTips":["Provision BILIBILI_COOKIE_{uid} for each uid before subscribing the unread feed.","Add a startup self-check that asserts the cookie exists for each enabled route.","Keep URL uid and env-var suffix byte-identical."],"tags":["config","authentication","bilibili","cookie","rsshub"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}