DIYgod/RSSHub · error · ConfigNotFoundError

缺少对应 uid 的 Bilibili 用户登录后的 Cookie 值

Error message

缺少对应 uid 的 Bilibili 用户登录后的 Cookie 值

What it means

ConfigNotFoundError thrown by the followings-video route when config.bilibili.cookies[uid] is undefined. This route fetches video-type dynamics (type=8) from the followed users' activity feed and requires authentication. The check fires before any network call.

Source

Thrown at lib/routes/bilibili/followings-video.ts:47

        supportPodcast: false,
        supportScihub: false,
    },
    name: '用户关注视频动态',
    maintainers: ['LogicJake'],
    handler,
    description: `::: warning
用户动态需要 b 站登录后的 Cookie 值,所以只能自建,详情见部署页面的配置模块。
:::`,
};

async function handler(ctx) {
    const uid = String(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.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/dynamic_new?uid=${uid}&type=8`,
        headers: {
            Referer: `https://space.bilibili.com/${uid}/`,
            Cookie: cookie,
        },
    });
    const data = response.data;
    if (data.code) {
        logger.error(JSON.stringify(data));
        if (data.code === -6 || data.code === 4_100_000) {
            throw new ConfigNotFoundError('对应 uid 的 Bilibili 用户的 Cookie 已过期');
        }
        throw new Error(`Got error code ${data.code} while fetching: ${data.message}`);
    }

View on GitHub (pinned to bed535e087)

Solutions

  1. Set BILIBILI_COOKIE_<uid> with a valid logged-in cookie for the account.
  2. Confirm the uid in the env var matches the route parameter.
  3. Restart RSSHub after setting the variable.

Example fix

// before: no cookie configured

// after
BILIBILI_COOKIE_123456=SESSDATA=xxx; bili_jct=xxx; DedeUserID=123456;
Defensive patterns

Strategy: validation

Validate before calling

const uid = String(ctx.req.param('uid'));
if (config.bilibili.cookies[uid] === undefined) {
    throw new ConfigNotFoundError(`No cookie for uid ${uid}`);
}

Type guard

function hasCookie(uid: string): boolean {
    return config.bilibili.cookies[uid] !== undefined;
}

Prevention

When it happens

Trigger: Requesting /bilibili/followings/video/:uid when no BILIBILI_COOKIE_<uid> env var is configured for that uid.

Common situations: Cookie not configured for the specific uid; env var name mismatch with route param; new self-hosted instance without bilibili config completed.

Related errors


AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12). Data as JSON: /api/errors/626a570493e59ac0. Report an issue: GitHub.