{"record":{"id":"449de0f152ef0c8d","repo":"DIYgod/RSSHub","slug":"uid-bilibili-cookie-449de0","errorCode":null,"errorMessage":"缺少对应 uid 的 Bilibili 用户登录后的 Cookie 值","messagePattern":"缺少对应 uid 的 Bilibili 用户登录后的 Cookie 值","errorType":"exception","errorClass":"ConfigNotFoundError","httpStatus":503,"severity":"error","filePath":"lib/routes/bilibili/message-sessions.ts","lineNumber":150,"sourceCode":"            case 12: // Article card\n                return `[专栏] ${parsed.title || ''}`;\n            case 14: // Bangumi card\n                return `[番剧] ${parsed.title || ''}`;\n            default:\n                return parsed.content || parsed.title || content;\n        }\n    } catch {\n        return content;\n    }\n}\n\nasync function handler(ctx) {\n    const uid = ctx.req.param('uid');\n    const name = await bilibiliCache.getUsernameFromUID(uid);\n\n    const cookie = config.bilibili.cookies[uid];\n    if (cookie === undefined) {\n        throw new ConfigNotFoundError('缺少对应 uid 的 Bilibili 用户登录后的 Cookie 值');\n    }\n\n    const response = await ofetch<SessionResponse>('https://api.vc.bilibili.com/session_svr/v1/session_svr/get_sessions', {\n        query: {\n            session_type: 1,\n            group_fold: 1,\n            unfollow_fold: 0,\n            sort_rule: 2,\n            build: 0,\n            mobi_app: 'web',\n        },\n        headers: {\n            Referer: 'https://message.bilibili.com/',\n            Cookie: cookie,\n        },\n    });\n\n    if (response.code !== 0) {","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/bilibili/message-sessions.ts#L132-L168","documentation":"ConfigNotFoundError thrown by /bilibili/message/sessions/:uid (private-message session list). The handler requires the per-uid Cookie to call https://api.vc.bilibili.com/session_svr/v1/session_svr/get_sessions; without BILIBILI_COOKIE_{uid} the cookies[uid] lookup is undefined and the route refuses to proceed. The dedicated subclass lets the host return a configuration-specific error.","triggerScenarios":"Requesting /bilibili/message/sessions/:uid when BILIBILI_COOKIE_{uid} (with that exact uid) is not present in the RSSHub environment.","commonSituations":"Env var not added on a new deploy; feed URL uid differs from the configured account; env var typo or not exported into the container; cookie configured for a different message route but not this uid.","solutions":["Set BILIBILI_COOKIE_{uid} (matching the URL uid) to the full bilibili.com logged-in Cookie and restart RSSHub.","Verify the variable is loaded: inspect config.bilibili.cookies keys, or `env | grep BILIBILI_COOKIE_` inside the container.","Ensure the uid in the URL is byte-for-byte the suffix used in the env var name."],"exampleFix":"// before: /bilibili/message/sessions/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 requireSessionsCookie(uid: string) {\n  if (config.bilibili.cookies[uid] === undefined) {\n    throw new Error(`BILIBILI_COOKIE_${uid} is required for /bilibili/message/sessions/${uid}`);\n  }\n}\nrequireSessionsCookie('2267573');","typeGuard":"function isConfigNotFoundError(e: unknown): e is Error {\n  return e instanceof Error && e.name === 'ConfigNotFoundError';\n}","tryCatchPattern":"try { await sessionsHandler(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 readers.","Add a startup check enumerating required cookies for the routes you expose.","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"}