{"record":{"id":"671941f3b6917854","repo":"DIYgod/RSSHub","slug":"uid-bilibili-cookie-671941","errorCode":null,"errorMessage":"缺少对应 uid 的 Bilibili 用户登录后的 Cookie 值","messagePattern":"缺少对应 uid 的 Bilibili 用户登录后的 Cookie 值","errorType":"exception","errorClass":"ConfigNotFoundError","httpStatus":503,"severity":"error","filePath":"lib/routes/bilibili/followings-dynamic.ts","lineNumber":68,"sourceCode":"    maintainers: ['TigerCubDen', 'JimenezLi'],\n    handler,\n    description: `::: warning\n用户动态需要 b 站登录后的 Cookie 值，所以只能自建，详情见部署页面的配置模块。\n:::`,\n};\n\nasync function handler(ctx) {\n    const uid = String(ctx.req.param('uid'));\n    const routeParams = querystring.parse(ctx.req.param('routeParams'));\n\n    const showEmoji = fallback(undefined, queryToBoolean(routeParams.showEmoji), false);\n    const embed = fallback(undefined, queryToBoolean(routeParams.embed), true);\n    const displayArticle = fallback(undefined, queryToBoolean(routeParams.displayArticle), false);\n\n    const name = await cache.getUsernameFromUID(uid);\n    const cookie = config.bilibili.cookies[uid];\n    if (cookie === undefined) {\n        throw new ConfigNotFoundError('缺少对应 uid 的 Bilibili 用户登录后的 Cookie 值');\n    }\n\n    const response = await got({\n        method: 'get',\n        url: `https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/dynamic_new?uid=${uid}&type_list=268435455`,\n        headers: {\n            Referer: `https://space.bilibili.com/${uid}/`,\n            Cookie: cookie,\n        },\n    });\n    if (response.data.code === -6) {\n        throw new ConfigNotFoundError('对应 uid 的 Bilibili 用户的 Cookie 已过期');\n    }\n    if (response.data.code === 4_100_000) {\n        throw new ConfigNotFoundError('对应 uid 的 Bilibili 用户 请求失败');\n    }\n    const data = JSONbig.parse(response.body).data.cards;\n","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/bilibili/followings-dynamic.ts#L50-L86","documentation":"ConfigNotFoundError thrown by the followings-dynamic route when config.bilibili.cookies[uid] is undefined. This route fetches the full dynamic feed (type_list=268435455 = all dynamic types) for a followed user's activity and requires a logged-in cookie to access Bilibili's dynamic_svr API. Without the cookie the request cannot be made at all.","triggerScenarios":"Requesting /bilibili/followings/dynamic/:uid without a matching BILIBILI_COOKIE_<uid> environment variable configured. The cookies map lookup returns undefined before any HTTP request is attempted.","commonSituations":"Operator configured cookies for one account but is requesting a different uid; env var naming mismatch (e.g., leading zeros, wrong case); new deployment that hasn't completed the bilibili cookie configuration step documented in the deploy guide.","solutions":["Add BILIBILI_COOKIE_<uid> to your environment with a valid cookie for the account matching :uid.","Ensure the uid segment in the env var name matches the route parameter exactly (both as strings).","Restart the RSSHub process/container so the new environment variable is picked up."],"exampleFix":"// before\n// .env has no BILIBILI_COOKIE_ entries\n\n// after\nBILIBILI_COOKIE_123456=SESSDATA=xxx; bili_jct=xxx; DedeUserID=123456;","handlingStrategy":"validation","validationCode":"const uid = String(ctx.req.param('uid'));\nif (!config.bilibili.cookies?.[uid]) {\n    throw new ConfigNotFoundError(`Cookie missing for uid ${uid}`);\n}","typeGuard":"function isCookieConfigured(uid: string): boolean {\n    return uid in (config.bilibili.cookies ?? {});\n}","tryCatchPattern":null,"preventionTips":["Maintain a list of all uids that have cookies configured.","Validate env vars at RSSHub startup.","Use consistent uid formatting (string, no leading zeros)."],"tags":["bilibili","config","cookie","authentication","rsshub"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}