DIYgod/RSSHub · error · ConfigNotFoundError

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

Error message

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

What it means

ConfigNotFoundError thrown by the followings-dynamic route when Bilibili's dynamic_new API returns code -6 after an authenticated request. This signals the cookie's SESSDATA is expired or invalid. The route had a cookie configured (so error 82 didn't fire) but the session is no longer recognized by Bilibili.

Source

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

    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;

    const getTitle = (data) => (data ? data.title || data.description || data.content || (data.vest && data.vest.content) || '' : '');
    const getDes = (data) =>
        data.dynamic || data.desc || data.description || data.content || data.summary || (data.vest && data.vest.content) + (data.sketch && `<br>${data.sketch.title}<br>${data.sketch.desc_text}`) || data.intro || '';
    const getOriginDes = (data) => (data && (data.apiSeasonInfo && data.apiSeasonInfo.title && `//转发自: ${data.apiSeasonInfo.title}`) + (data.index_title && `<br>${data.index_title}`)) || '';
    const getOriginName = (data) => data.uname || (data.author && data.author.name) || (data.upper && data.upper.name) || (data.user && (data.user.uname || data.user.name)) || (data.owner && data.owner.name) || '';
    const getOriginTitle = (data) => (data.title ? `${data.title}<br>` : '');
    const getIframe = (data) => {
        if (!embed) {
            return '';
        }
        const aid = data?.aid;
        const bvid = data?.bvid;

View on GitHub (pinned to bed535e087)

Solutions

  1. Re-log into bilibili.com, copy the fresh Cookie header, and update BILIBILI_COOKIE_<uid>.
  2. Restart RSSHub to load the updated cookie.
  3. Verify the account is not restricted/banned, which can also produce auth-level errors.

Example fix

// before: stale cookie in env
BILIBILI_COOKIE_123456=SESSDATA=expired;...

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

Strategy: retry

Try / catch

try {
    const response = await got({...});
    if (response.data.code === -6) {
        logger.error(`Cookie expired for uid=${uid}`);
        throw new ConfigNotFoundError('Cookie expired');
    }
    if (response.data.code === 4_100_000) {
        throw new ConfigNotFoundError('Request rejected by risk control');
    }
} catch (e) {
    throw e;
}

Prevention

When it happens

Trigger: The dynamic_svr/v1/dynamic_svr/dynamic_new endpoint returns code -6 for the configured cookie, meaning Bilibili considers the session unauthenticated. Occurs after SESSDATA expiry, password change, or manual logout on the source account.

Common situations: Long-running deployment with a stale cookie; SESSDATA rotated by Bilibili's security system; cookie copied without the SESSDATA field; account password was changed.

Related errors


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