DIYgod/RSSHub · error · ConfigNotFoundError

什么值得买排行榜 is disabled due to the lack of SMZDM_COOKIE

Error message

什么值得买排行榜 is disabled due to the lack of SMZDM_COOKIE

What it means

Thrown as a ConfigNotFoundError when config.smzdm.cookie is falsy in the SMZDM keyword-search route (/smzdm/keyword/:keyword). The route scrapes search.smzdm.com which requires a cookie to pass anti-crawler checks. The error message '排行榜' (rankings) is a copy-paste artifact — this route performs keyword search, not rankings.

Source

Thrown at lib/routes/smzdm/keyword.ts:39

            {
                name: 'SMZDM_COOKIE',
                description: '什么值得买登录后的 Cookie 值',
            },
        ],
        requirePuppeteer: false,
        antiCrawler: false,
        supportBT: false,
        supportPodcast: false,
        supportScihub: false,
    },
    name: '关键词',
    maintainers: ['DIYgod', 'MeanZhang'],
    handler,
};

async function handler(ctx) {
    if (!config.smzdm.cookie) {
        throw new ConfigNotFoundError('什么值得买排行榜 is disabled due to the lack of SMZDM_COOKIE');
    }

    const keyword = ctx.req.param('keyword');

    const response = await got('https://search.smzdm.com', {
        headers: {
            ...getHeaders(),
            Referer: `https://search.smzdm.com/?c=home&s=${encodeURIComponent(keyword)}&order=time&v=a`,
        },
        searchParams: {
            c: 'home',
            s: keyword,
            order: 'time',
            v: 'a',
            mx_v: 'a',
        },
    });

View on GitHub (pinned to bed535e087)

Solutions

  1. Set SMZDM_COOKIE with a valid session cookie from a logged-in smzdm.com session.
  2. Refresh the cookie if it expired and restart RSSHub.
  3. Use unauthenticated SMZDM routes if credentials are unavailable.

Example fix

# before
# (SMZDM_COOKIE not set)

# after (.env)
SMZDM_COOKIE=smzdm_id=...; smzdm_sess=...; usera=...;
Defensive patterns

Strategy: validation

Validate before calling

if (!config.smzdm?.cookie) {
    throw new ConfigNotFoundError('SMZDM keyword search RSS requires SMZDM_COOKIE.');
}

Type guard

function hasSmzdmCookie(cfg: typeof config): cfg is typeof config & { smzdm: { cookie: string } } {
    return !!cfg.smzdm && typeof cfg.smzdm.cookie === 'string' && cfg.smzdm.cookie.length > 0;
}

Prevention

When it happens

Trigger: The RSSHub instance has not set SMZDM_COOKIE. Any request to /smzdm/keyword/:keyword triggers this immediately.

Common situations: Self-hosted RSSHub without SMZDM_COOKIE; cookie expired; public instance without SMZDM support.

Related errors


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