{"record":{"id":"19a8497383782593","repo":"DIYgod/RSSHub","slug":"uid-bilibili-cookie-19a849","errorCode":null,"errorMessage":"对应 uid 的 Bilibili 用户的 Cookie 已过期","messagePattern":"对应 uid 的 Bilibili 用户的 Cookie 已过期","errorType":"exception","errorClass":"ConfigNotFoundError","httpStatus":503,"severity":"error","filePath":"lib/routes/bilibili/followings-article.ts","lineNumber":56,"sourceCode":"async function handler(ctx) {\n    const uid = String(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 got({\n        method: 'get',\n        url: `https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/dynamic_new?uid=${uid}&type=64`,\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    const cards = response.data.data.cards;\n\n    const out = await Promise.all(\n        cards.map(async (card) => {\n            const card_data = JSON.parse(card.card);\n            const { url: link, description } = await cache.getArticleDataFromCvid(card_data.id, uid);\n\n            const item = {\n                title: card_data.title,\n                description,\n                pubDate: new Date(card_data.publish_time * 1000).toUTCString(),\n                link,\n                author: card.desc.user_profile.info.uname,\n            };\n            return item;\n        })\n    );","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/bilibili/followings-article.ts#L38-L74","documentation":"ConfigNotFoundError thrown when Bilibili's dynamic_svr API returns code -6, indicating the configured Cookie for the uid has expired or the session is no longer valid. The followings-article route checks response.data.code after the authenticated request and maps -6 to this expired-cookie error. Bilibili sessions (SESSDATA) expire periodically, so a previously working deployment will start failing.","triggerScenarios":"The dynamic_new API (type=64) responds with {\"code\":-6,...} meaning 'account not logged in / credentials invalid'. This happens after SESSDATA expires, the user logged out of the account on the web, or Bilibili invalidated the session for security reasons.","commonSituations":"Cookie was set weeks/months ago and SESSDATA naturally expired; the account owner changed their password causing all sessions to invalidate; Bilibili rotated the session token; the cookie string was copied incompletely (missing SESSDATA).","solutions":["Log into bilibili.com in a browser, re-copy the full Cookie (especially SESSDATA and DedeUserID), and update BILIBILI_COOKIE_<uid>.","Restart RSSHub after updating the env var so the new cookie is loaded.","If the error persists immediately after updating, verify SESSDATA is present in the cookie string and the account is not locked."],"exampleFix":"// before: expired cookie\nBILIBILI_COOKIE_123456=SESSDATA=old_expired_value;...\n\n// after: fresh cookie from browser\nBILIBILI_COOKIE_123456=SESSDATA=new_valid_value; bili_jct=xxx; DedeUserID=123456;","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    const response = await got({...});\n    if (response.data.code === -6) {\n        // Optionally: alert the operator to refresh the cookie\n        logger.warn(`Cookie expired for uid=${uid}. Update BILIBILI_COOKIE_${uid}.`);\n        throw new ConfigNotFoundError('Cookie expired');\n    }\n} catch (e) {\n    if (e instanceof ConfigNotFoundError) {\n        // Surface as a config error, not a crash\n    }\n    throw e;\n}","preventionTips":["Set up monitoring/alerting that detects repeated -6 codes and notifies you to refresh cookies.","Schedule periodic cookie refreshes before SESSDATA expiry (typically every few weeks).","Keep a documented procedure for extracting fresh cookies from the browser."],"tags":["bilibili","cookie","authentication","session-expiry","rsshub"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}