DIYgod/RSSHub · error
message ?? code
Error message
message ?? code
What it means
Thrown by the bilibili favorites (fav) route when the fav/resource/list API returns a non-zero code. The message is the API's own message (preferred) or the numeric code, propagated verbatim. The request already attached config.bilibili.cookies[uid], so a non-zero code usually means auth or visibility problems.
Source
Thrown at lib/routes/bilibili/fav.ts:40
maintainers: ['Qixingchen'],
handler,
};
async function handler(ctx) {
const fid = ctx.req.param('fid');
const uid = ctx.req.param('uid');
const embed = !ctx.req.param('embed');
const response = await got({
url: `https://api.bilibili.com/x/v3/fav/resource/list?media_id=${fid}&ps=20`,
headers: {
Referer: `https://space.bilibili.com/${uid}/`,
Cookie: config.bilibili.cookies[uid],
},
});
const { data, code, message } = response.data;
if (code) {
throw new Error(message ?? code);
}
const username = data.info.upper.name;
const favName = data.info.title;
return {
title: `${username} 的 bilibili 收藏夹 ${favName}`,
link: `https://space.bilibili.com/${uid}/#/favlist?fid=${fid}`,
description: `${username} 的 bilibili 收藏夹 ${favName}`,
item:
data.medias &&
data.medias.map((item) => ({
title: item.title,
description: utils.renderUGCDescription(embed, item.cover, item.intro, item.id, undefined, item.bvid),
pubDate: parseDate(item.fav_time * 1000),
link: item.fav_time > utils.bvidTime && item.bvid ? `https://www.bilibili.com/video/${item.bvid}` : `https://www.bilibili.com/video/av${item.id}`,
author: item.upper.name,View on GitHub (pinned to bed535e087)
Solutions
- Inspect the propagated code: -101 means the cookie for uid is invalid/missing (set config.bilibili.cookies[uid]); -403 means the folder is private.
- Confirm fid is a public favorites folder owned by uid.
- Re-copy the cookie from a logged-in bilibili.com session and restart RSSHub.
Example fix
// before
const { data, code, message } = response.data;
if (code) {
throw new Error(message ?? code);
}
// after
if (code) {
if (code === -101) {
throw new ConfigNotFoundError(`bilibili cookie for uid ${uid} is missing or expired (code -101).`);
}
throw new Error(`bilibili fav API error for uid ${uid} fid ${fid}: ${message ?? code}`);
} Defensive patterns
Strategy: try-catch
Validate before calling
const { code, message } = response.data ?? {};
if (code) {
throw new Error(message ?? String(code));
} Type guard
function isBilibiliErrorEnvelope(r: any): boolean {
return r && typeof r.code === 'number' && r.code !== 0;
} Try / catch
try {
const { data, code, message } = response.data;
if (code) throw new Error(message ?? code);
} catch (e) {
if (/^-101|-403/.test(String((e as Error).message))) {
// cookie expired or folder private — surface to operator
}
throw e;
} Prevention
- Confirm the favorites folder (fid) is public and belongs to uid before requesting.
- Keep config.bilibili.cookies[uid] fresh so auth codes do not surface to feed readers.
When it happens
Trigger: Requesting /bilibili/fav/:uid/:fid and the API returns code != 0: the fav list is private, the cookie for uid is missing/expired, or fid does not belong to uid.
Common situations: config.bilibili.cookies[uid] unset or expired; target favorited folder set to private; fid typo or a folder that was deleted.
Related errors
- message ?? code
- 缺少对应 loginUid 的 Bilibili 用户登录后的 Cookie 值 <a href="https://do
- 对应 loginUid 的 Bilibili 用户的 Cookie 已过期
- 缺少对应 uid 的 Bilibili 用户登录后的 Cookie 值
- 对应 uid 的 Bilibili 用户的 Cookie 已过期
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/70200cd6f0191f94.
Report an issue: GitHub.