DIYgod/RSSHub · error · ConfigNotFoundError

对应 uid 的 Bilibili 用户的 Cookie 已过期

Error message

对应 uid 的 Bilibili 用户的 Cookie 已过期

What it means

ConfigNotFoundError thrown by the followings-video route when the dynamic_new API returns a non-zero code that is either -6 (session expired) or 4100000 (risk-control rejection). The route lumps both codes into the same 'cookie expired' message. This is slightly imprecise: -6 is genuinely an expired cookie, while 4100000 is a risk-control failure that may not be cookie-related.

Source

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

    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}`);
    }
    const cards = data.data.cards;

    const out = cards.map((card) => {
        const card_data = JSON.parse(card.card);

        return {
            title: card_data.title,
            description: utils.renderUGCDescription(embed, card_data.pic, card_data.desc, card_data.aid, undefined, card.desc.bvid),
            pubDate: new Date(card_data.pubdate * 1000).toUTCString(),
            link: card_data.pubdate > utils.bvidTime && card.desc.bvid ? `https://www.bilibili.com/video/${card.desc.bvid}` : `https://www.bilibili.com/video/av${card_data.aid}`,
            author: card.desc.user_profile.info.uname,
        };
    });

    return {

View on GitHub (pinned to bed535e087)

Solutions

  1. Refresh BILIBILI_COOKIE_<uid> with a new SESSDATA from a browser login session.
  2. If code is 4100000 specifically, also reduce request frequency and consider a residential proxy.
  3. Restart RSSHub after updating the cookie.
  4. Check server logs (logger.error outputs the full data object) to distinguish -6 vs 4100000.

Example fix

// before
if (data.code === -6 || data.code === 4_100_000) {
    throw new ConfigNotFoundError('对应 uid 的 Bilibili 用户的 Cookie 已过期');
}

// after: distinguish the two codes for clearer diagnostics
if (data.code === -6) {
    throw new ConfigNotFoundError('Cookie 已过期,请更新 BILIBILI_COOKIE_' + uid);
}
if (data.code === 4_100_000) {
    throw new HTTPError('Bilibili 风控拦截,请降低频率或更换 IP');
}
Defensive patterns

Strategy: try-catch

Try / catch

try {
    const response = await got({...});
    if (response.data.code) {
        if (response.data.code === -6 || response.data.code === 4_100_000) {
            throw new ConfigNotFoundError('Cookie expired or risk-controlled');
        }
        throw new Error(`Code ${response.data.code}: ${response.data.message}`);
    }
} catch (e) {
    logger.error(`followings-video failed: ${e.message}`);
    throw e;
}

Prevention

When it happens

Trigger: response.data.code is truthy (non-zero) and equals -6 or 4100000. Code -6 = SESSDATA invalid/expired; code 4100000 = request flagged by Bilibili risk control.

Common situations: Expired SESSDATA after weeks of use; datacenter IP flagged for automation; cookie invalidated by password change; both auth and risk-control failures surface identically to the user.

Related errors


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