DIYgod/RSSHub · error · ConfigNotFoundError

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

Error message

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

What it means

ConfigNotFoundError thrown by /bilibili/message/system/:uid (system notifications feed). The handler needs the per-uid Cookie to call https://message.bilibili.com/x/sys-msg/query_user_notify; if BILIBILI_COOKIE_{uid} is absent, cookies[uid] is undefined and the route aborts before the request. The subclass lets the host treat it as a missing-config condition.

Source

Thrown at lib/routes/bilibili/message-system.ts:93

}

/**
 * Parse bilibili message content with special link format
 * Format: #{text}{"url"} -> <a href="url">text</a>
 */
function parseMessageContent(content: string): string {
    // Match pattern like #{text}{"url"}
    const linkPattern = /#\{([^}]+)\}\{"([^"]+)"\}/g;
    return content.replaceAll(linkPattern, '<a href="$2">$1</a>');
}

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<SystemResponse>('https://message.bilibili.com/x/sys-msg/query_user_notify', {
        query: {
            page_size: 20,
            build: 0,
            mobi_app: 'web',
        },
        headers: {
            Referer: 'https://message.bilibili.com/',
            Cookie: cookie,
        },
    });

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

View on GitHub (pinned to bed535e087)

Solutions

  1. Define BILIBILI_COOKIE_{uid} (matching the URL uid) with the full logged-in bilibili.com Cookie, then restart RSSHub.
  2. Confirm the variable is loaded into the process (config.bilibili.cookies keys or `env | grep BILIBILI_COOKIE_`).
  3. Make sure the URL uid and env var suffix match exactly (string comparison).

Example fix

// before: /bilibili/message/system/2267573 with no env -> ConfigNotFoundError

// after:
//   BILIBILI_COOKIE_2267573=SESSDATA=...; bili_jct=...; DedeUserID=2267573; ...
Defensive patterns

Strategy: validation

Validate before calling

import { config } from '@/config';
function requireSystemCookie(uid: string) {
  if (config.bilibili.cookies[uid] === undefined) {
    throw new Error(`Set BILIBILI_COOKIE_${uid} for /bilibili/message/system/${uid}`);
  }
}
requireSystemCookie('2267573');

Type guard

function isConfigNotFoundError(e: unknown): e is Error {
  return e instanceof Error && e.name === 'ConfigNotFoundError';
}

Try / catch

try { await systemHandler(ctx); }
catch (e) {
  if (e instanceof Error && e.name === 'ConfigNotFoundError') {
    ctx.status = 503; ctx.body = { error: 'Missing BILIBILI_COOKIE_' + uid }; return;
  }
  throw e;
}

Prevention

When it happens

Trigger: Requesting /bilibili/message/system/:uid when no BILIBILI_COOKIE_{uid} env var is defined for that uid on the RSSHub host.

Common situations: Fresh deploy without the cookie env var; URL uid differs from the configured account; env var name typo or not exported into the container runtime.

Related errors


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