DIYgod/RSSHub · error · ConfigNotFoundError
缺少对应 uid 的 Bilibili 用户登录后的 Cookie 值
Error message
缺少对应 uid 的 Bilibili 用户登录后的 Cookie 值
What it means
ConfigNotFoundError thrown by the bilibili/watchlater handler when config.bilibili.cookies[uid] is undefined. The watch-later feed is private and strictly requires the logged-in user's cookie, so a missing entry is treated as a configuration problem rather than a runtime error, surfacing a clear setup message to the operator.
Source
Thrown at lib/routes/bilibili/watchlater.ts:47
supportPodcast: false,
supportScihub: false,
},
name: '用户稍后再看',
maintainers: ['JimenezLi'],
handler,
description: `::: warning
用户稍后再看需要 b 站登录后的 Cookie 值,所以只能自建,详情见部署页面的配置模块。
:::`,
};
async function handler(ctx) {
const uid = ctx.req.param('uid');
const embed = !ctx.req.param('embed');
const name = await cache.getUsernameFromUID(uid);
const cookie = config.bilibili.cookies[uid];
if (cookie === undefined) {
throw new ConfigNotFoundError('缺少对应 uid 的 Bilibili 用户登录后的 Cookie 值');
}
const response = await got({
method: 'get',
url: 'https://api.bilibili.com/x/v2/history/toview',
headers: {
Referer: `https://space.bilibili.com/${uid}/`,
Cookie: cookie,
},
});
if (response.data.code) {
const message = response.data.code === -6 ? '对应 uid 的 Bilibili 用户的 Cookie 已过期' : response.data.message;
throw new ConfigNotFoundError(`Error code ${response.data.code}: ${message}`);
}
const list = response.data.data.list || [];
const out = list.map((item) => ({
title: item.title,View on GitHub (pinned to bed535e087)
Solutions
- Set BILIBILI_COOKIE_{uid} in the environment (replace {uid} with the target user id, e.g. BILIBILI_COOKIE_2267573).
- Copy the full Cookie header from a logged-in bilibili.com session (Network panel on api.bilibili.com).
- Restart RSSHub so the config module picks up the new env var.
- Confirm the uid in the route matches the uid suffix of the env variable name.
Example fix
# before: no env var set -> error # after export BILIBILI_COOKIE_2267573='SESSDATA=xxx; bili_jct=yyy; DedeUserID=2267573'
Defensive patterns
Strategy: validation
Validate before calling
const uid = ctx.req.param('uid');
if (config.bilibili.cookies[uid] === undefined) {
throw new ConfigNotFoundError(`Set BILIBILI_COOKIE_${uid} to use the watchlater feed`);
} Type guard
const hasCookieForUid = (uid: string): boolean =>
typeof config.bilibili.cookies[uid] === 'string' && config.bilibili.cookies[uid].length > 0; Prevention
- Document the BILIBILI_COOKIE_{uid} naming convention in deployment docs.
- Add a startup health check listing which uids have cookies configured.
- Treat a missing cookie as a 4xx-style config error (ConfigNotFoundError), not a 5xx.
When it happens
Trigger: A request to /bilibili/watchlater/:uid where no environment variable BILIBILI_COOKIE_{uid} was provided, so config.bilibili.cookies has no key for that uid.
Common situations: Self-hosting RSSHub without setting the per-uid cookie env var; using a uid that was never registered in config; cookie env var typo such as BILIBILI_COOKIE instead of BILIBILI_COOKIE_2267573.
Related errors
- 缺少对应 loginUid 的 Bilibili 用户登录后的 Cookie 值 <a href="https://do
- 缺少对应 uid 的 Bilibili 用户登录后的 Cookie 值
- 缺少对应 uid 的 Bilibili 用户登录后的 Cookie 值
- 缺少对应 uid 的 Bilibili 用户登录后的 Cookie 值
- 缺少对应 loginUid 的 Bilibili 用户登录后的 Cookie 值 <a href="https://do
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/5192d95ea1353d8d.
Report an issue: GitHub.