{"record":{"id":"f86d16728cc37b23","repo":"DIYgod/RSSHub","slug":"uid-bilibili-cookie-f86d16","errorCode":null,"errorMessage":"缺少对应 uid 的 Bilibili 用户登录后的 Cookie 值","messagePattern":"缺少对应 uid 的 Bilibili 用户登录后的 Cookie 值","errorType":"exception","errorClass":"ConfigNotFoundError","httpStatus":503,"severity":"error","filePath":"lib/routes/bilibili/message-reply.ts","lineNumber":99,"sourceCode":"    ttl: number;\n    data: {\n        cursor: {\n            is_end: boolean;\n            id: number;\n            time: number;\n        };\n        items: ReplyItem[];\n        last_view_at: 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    const response = await ofetch<ReplyResponse>('https://api.bilibili.com/x/msgfeed/reply', {\n        query: {\n            platform: 'web',\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) {\n        throw new Error(response.message ?? `Error code ${response.code}`);\n    }\n","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/bilibili/message-reply.ts#L81-L117","documentation":"Same ConfigNotFoundError pattern as the other bilibili message routes, this time for /bilibili/message/reply/:uid (replies-to-me feed). The handler reads config.bilibili.cookies[uid]; if undefined it throws before calling https://api.bilibili.com/x/msgfeed/reply, because that endpoint requires the logged-in user's session Cookie. The dedicated subclass lets RSSHub distinguish a missing-config condition from a runtime API failure.","triggerScenarios":"Requesting /bilibili/message/reply/:uid with no BILIBILI_COOKIE_{uid} env var defined for that exact uid on the RSSHub host.","commonSituations":"Cookie env var not provisioned on a fresh deploy; uid in the feed URL is a different account than the one configured; env var misnamed (e.g. BILIBILI_COOKIE without _{uid}, or uid zero-padded differently).","solutions":["Define BILIBILI_COOKIE_{uid} (matching the uid in the URL) with the full logged-in bilibili.com Cookie, then restart the RSSHub process.","Confirm the variable reaches the process — check `config.bilibili.cookies` keys in a debug endpoint or `env | grep BILIBILI_COOKIE_` in the container shell.","Make sure the uid token in the URL is the same string used as the env var suffix (string equality, not numeric — leading zeros would diverge)."],"exampleFix":"// before: request /bilibili/message/reply/2267573 with no env -> ConfigNotFoundError\n\n// after: set env then restart\n//   BILIBILI_COOKIE_2267573=SESSDATA=...; bili_jct=...; DedeUserID=2267573; ...","handlingStrategy":"validation","validationCode":"import { config } from '@/config';\n\nfunction requireBilibiliCookieForUid(uid: string) {\n  if (config.bilibili.cookies[uid] === undefined) {\n    throw new Error(`Set BILIBILI_COOKIE_${uid} before subscribing to /bilibili/message/reply/${uid}`);\n  }\n}\nrequireBilibiliCookieForUid('2267573');","typeGuard":"function isConfigNotFoundError(e: unknown): e is Error {\n  return e instanceof Error && e.name === 'ConfigNotFoundError';\n}","tryCatchPattern":"try {\n  await replyHandler(ctx);\n} catch (e) {\n  if (e instanceof Error && e.name === 'ConfigNotFoundError') {\n    ctx.status = 503;\n    ctx.body = { error: 'Missing BILIBILI_COOKIE_' + uid };\n    return;\n  }\n  throw e;\n}","preventionTips":["Provision BILIBILI_COOKIE_{uid} for every uid you plan to serve before subscribing any reader.","Validate cookie presence at startup with a self-check route.","Treat the env-var suffix as a string identical to the URL uid token."],"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"}