DIYgod/RSSHub · error · ConfigNotFoundError

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

Error message

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

What it means

ConfigNotFoundError thrown by the message-at ('@ mentions') route when config.bilibili.cookies[uid] is undefined. This route fetches the user's @-mention notifications from /x/msgfeed/at, which is strictly private/account-scoped data requiring authentication. Without the cookie, the API call cannot be made.

Source

Thrown at lib/routes/bilibili/message-at.ts:89

    message: string;
    ttl: number;
    data: {
        cursor: {
            is_end: boolean;
            id: number;
            time: number;
        };
        items: AtItem[];
    };
}

async function handler(ctx) {
    const uid = ctx.req.param('uid');
    const name = await cache.getUsernameFromUID(uid);

    const cookie = config.bilibili.cookies[uid];
    if (cookie === undefined) {
        throw new ConfigNotFoundError('缺少对应 uid 的 Bilibili 用户登录后的 Cookie 值');
    }

    const response = await ofetch<AtResponse>('https://api.bilibili.com/x/msgfeed/at', {
        query: {
            platform: 'web',
            build: 0,
            mobi_app: 'web',
        },
        headers: {
            Referer: 'https://message.bilibili.com/',
            Cookie: cookie,
        },
    });

    if (response.code !== 0) {
        throw new Error(response.message ?? `Error code ${response.code}`);
    }

View on GitHub (pinned to bed535e087)

Solutions

  1. Set BILIBILI_COOKIE_<uid> with a cookie from the account whose mentions you want.
  2. Ensure the uid in the env var name matches the route parameter.
  3. Restart RSSHub after configuration.

Example fix

// before: no cookie for message routes

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

Strategy: validation

Validate before calling

const uid = ctx.req.param('uid');
if (!config.bilibili.cookies?.[uid]) {
    throw new ConfigNotFoundError(`Set BILIBILI_COOKIE_${uid} to read @ mentions`);
}

Type guard

function hasMessageCookie(uid: string): boolean {
    return typeof config.bilibili.cookies?.[uid] === 'string';
}

Prevention

When it happens

Trigger: Requesting /bilibili/messages/at/:uid without BILIBILI_COOKIE_<uid> configured. The msgfeed API requires the account owner's session to read their personal mention notifications.

Common situations: Cookie not configured for the uid; uid in route doesn't match any env var; new deployment without the bilibili cookie setup step.

Related errors


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