{"record":{"id":"8aa6aeb98d922fe1","repo":"DIYgod/RSSHub","slug":"uid-bilibili-cookie-8aa6ae","errorCode":null,"errorMessage":"缺少对应 uid 的 Bilibili 用户登录后的 Cookie 值","messagePattern":"缺少对应 uid 的 Bilibili 用户登录后的 Cookie 值","errorType":"exception","errorClass":"ConfigNotFoundError","httpStatus":503,"severity":"error","filePath":"lib/routes/bilibili/message-system.ts","lineNumber":93,"sourceCode":"}\n\n/**\n * Parse bilibili message content with special link format\n * Format: #{text}{\"url\"} -> <a href=\"url\">text</a>\n */\nfunction parseMessageContent(content: string): string {\n    // Match pattern like #{text}{\"url\"}\n    const linkPattern = /#\\{([^}]+)\\}\\{\"([^\"]+)\"\\}/g;\n    return content.replaceAll(linkPattern, '<a href=\"$2\">$1</a>');\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<SystemResponse>('https://message.bilibili.com/x/sys-msg/query_user_notify', {\n        query: {\n            page_size: 20,\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 ?? response.msg ?? `Error code ${response.code}`);\n    }\n","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/bilibili/message-system.ts#L75-L111","documentation":"ConfigNotFoundError thrown by /bilibili/message/system/:uid (system notifications feed). The handler needs the per-uid Cookie to call https://message.bilibili.com/x/sys-msg/query_user_notify; if BILIBILI_COOKIE_{uid} is absent, cookies[uid] is undefined and the route aborts before the request. The subclass lets the host treat it as a missing-config condition.","triggerScenarios":"Requesting /bilibili/message/system/:uid when no BILIBILI_COOKIE_{uid} env var is defined for that uid on the RSSHub host.","commonSituations":"Fresh deploy without the cookie env var; URL uid differs from the configured account; env var name typo or not exported into the container runtime.","solutions":["Define BILIBILI_COOKIE_{uid} (matching the URL uid) with the full logged-in bilibili.com Cookie, then restart RSSHub.","Confirm the variable is loaded into the process (config.bilibili.cookies keys or `env | grep BILIBILI_COOKIE_`).","Make sure the URL uid and env var suffix match exactly (string comparison)."],"exampleFix":"// before: /bilibili/message/system/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 requireSystemCookie(uid: string) {\n  if (config.bilibili.cookies[uid] === undefined) {\n    throw new Error(`Set BILIBILI_COOKIE_${uid} for /bilibili/message/system/${uid}`);\n  }\n}\nrequireSystemCookie('2267573');","typeGuard":"function isConfigNotFoundError(e: unknown): e is Error {\n  return e instanceof Error && e.name === 'ConfigNotFoundError';\n}","tryCatchPattern":"try { await systemHandler(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":["Set BILIBILI_COOKIE_{uid} for every uid you serve before subscribing readers.","Self-check cookie presence at startup.","Keep URL uid token identical to the env-var suffix."],"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"}