DIYgod/RSSHub · error · ConfigNotFoundError

BAIDU_COOKIE must contain BDUSS. Please check your cookie co

Error message

BAIDU_COOKIE must contain BDUSS. Please check your cookie configuration.

What it means

ConfigNotFoundError thrown by getTiebaForumData after confirming a cookie exists but failing to extract a BDUSS value from it (the regex /BDUSS=([^;]+)/ did not match). BDUSS is the long-lived auth token the mobile API signs requests with, so a cookie without it cannot authenticate and the route refuses to proceed rather than sending an unsigned request.

Source

Thrown at lib/routes/baidu/tieba/common.ts:147

 */
const TIEBA_CLIENT_SECRET = 'tiebaclient!!!';

function computeSign(params: Record<string, string>): string {
    // oxlint-disable-next-line unicorn-js/require-array-sort-compare
    const sortedKeys = Object.keys(params).toSorted();
    const raw = sortedKeys.map((key) => `${key}=${params[key]}`).join('') + TIEBA_CLIENT_SECRET;
    return createHash('md5').update(raw).digest('hex');
}

export async function getTiebaForumData(params: { kw: string; cid?: string; isGood?: boolean; sortBy?: string }): Promise<any> {
    const cookie = config.baidu.cookie;
    if (!cookie) {
        throw new ConfigNotFoundError('Baidu Tieba RSS is disabled due to the lack of <a href="https://docs.rsshub.app/deploy/config#baidu">BAIDU_COOKIE</a>');
    }

    const bduss = cookie.match(/BDUSS=([^;]+)/)?.[1] || '';
    if (!bduss) {
        throw new ConfigNotFoundError('BAIDU_COOKIE must contain BDUSS. Please check your cookie configuration.');
    }

    const apiParams: Record<string, string> = {
        _client_id: 'wappc_1234567890123_456',
        _client_type: '2',
        _client_version: '12.20.1.0',
        _phone_imei: '000000000000000',
        from: 'tieba',
        kw: params.kw,
        rn: '30',
        pn: '1',
        BDUSS: bduss,
    };

    if (params.isGood) {
        apiParams.is_good = '1';
    }
    if (params.cid && params.cid !== '0') {

View on GitHub (pinned to bed535e087)

Solutions

  1. Re-copy the full cookie from a logged-in tieba.baidu.com request, making sure the BDUSS=... entry is included (it is HttpOnly, so use devtools Application > Cookies or the full Cookie request header).
  2. Validate the string contains 'BDUSS=' before setting it; restart RSSHub.

Example fix

// before
const bduss = cookie.match(/BDUSS=([^;]+)/)?.[1] || '';
if (!bduss) {
    throw new ConfigNotFoundError('BAIDU_COOKIE must contain BDUSS. Please check your cookie configuration.');
}

// after: surface what was found so the operator can diagnose
if (!cookie.includes('BDUSS=')) {
    throw new ConfigNotFoundError('BAIDU_COOKIE must contain a BDUSS entry. Re-copy the cookie from a logged-in tieba.baidu.com session including HttpOnly cookies.');
}
Defensive patterns

Strategy: validation

Validate before calling

const bduss = /BDUSS=([^;]+)/.exec(config.baidu.cookie ?? '')?.[1];
if (!bduss) {
    throw new ConfigNotFoundError('BAIDU_COOKIE must contain a BDUSS entry.');
}

Type guard

function cookieHasBduss(cookie: string): boolean {
    return /BDUSS=[^;]+/.test(cookie);
}

Prevention

When it happens

Trigger: BAIDU_COOKIE is set but does not contain a BDUSS=... entry, e.g. only PTSIG/STOKEN/login logs were copied, or the cookie string was truncated.

Common situations: Operator copied only part of the cookie; cookie export tool omitted HttpOnly BDUSS; BDUSS was renamed/dropped by Baidu (unlikely).

Related errors


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