DIYgod/RSSHub · error · ConfigNotFoundError

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

Error message

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

What it means

ConfigNotFoundError thrown by the followings-dynamic route when config.bilibili.cookies[uid] is undefined. This route fetches the full dynamic feed (type_list=268435455 = all dynamic types) for a followed user's activity and requires a logged-in cookie to access Bilibili's dynamic_svr API. Without the cookie the request cannot be made at all.

Source

Thrown at lib/routes/bilibili/followings-dynamic.ts:68

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

async function handler(ctx) {
    const uid = String(ctx.req.param('uid'));
    const routeParams = querystring.parse(ctx.req.param('routeParams'));

    const showEmoji = fallback(undefined, queryToBoolean(routeParams.showEmoji), false);
    const embed = fallback(undefined, queryToBoolean(routeParams.embed), true);
    const displayArticle = fallback(undefined, queryToBoolean(routeParams.displayArticle), false);

    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_list=268435455`,
        headers: {
            Referer: `https://space.bilibili.com/${uid}/`,
            Cookie: cookie,
        },
    });
    if (response.data.code === -6) {
        throw new ConfigNotFoundError('对应 uid 的 Bilibili 用户的 Cookie 已过期');
    }
    if (response.data.code === 4_100_000) {
        throw new ConfigNotFoundError('对应 uid 的 Bilibili 用户 请求失败');
    }
    const data = JSONbig.parse(response.body).data.cards;

View on GitHub (pinned to bed535e087)

Solutions

  1. Add BILIBILI_COOKIE_<uid> to your environment with a valid cookie for the account matching :uid.
  2. Ensure the uid segment in the env var name matches the route parameter exactly (both as strings).
  3. Restart the RSSHub process/container so the new environment variable is picked up.

Example fix

// before
// .env has no BILIBILI_COOKIE_ entries

// 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]) {
    throw new ConfigNotFoundError(`Cookie missing for uid ${uid}`);
}

Type guard

function isCookieConfigured(uid: string): boolean {
    return uid in (config.bilibili.cookies ?? {});
}

Prevention

When it happens

Trigger: Requesting /bilibili/followings/dynamic/:uid without a matching BILIBILI_COOKIE_<uid> environment variable configured. The cookies map lookup returns undefined before any HTTP request is attempted.

Common situations: Operator configured cookies for one account but is requesting a different uid; env var naming mismatch (e.g., leading zeros, wrong case); new deployment that hasn't completed the bilibili cookie configuration step documented in the deploy guide.

Related errors


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