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 product-wiki route (/smzdm/product/:id). The route scrapes wiki.smzdm.com/p/:id which requires a cookie for anti-crawler access. The error message '排行榜' (rankings) is a copy-paste artifact — this route fetches product wiki pages, not rankings.

Source

Thrown at lib/routes/smzdm/product.ts:42

        antiCrawler: false,
        supportBT: false,
        supportPodcast: false,
        supportScihub: false,
    },
    radar: [
        {
            source: ['wiki.smzdm.com/p/:id'],
            target: '/product/:id',
        },
    ],
    name: '商品',
    maintainers: ['chesha1'],
    handler,
};

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

    const link = `https://wiki.smzdm.com/p/${ctx.req.param('id')}`;

    const response = await ofetch(link, {
        headers: getHeaders(),
    });
    const $ = load(response);
    const title = $('title').text();

    // get simple info from list
    const items: DataItem[] = $('ul#feed-main-list li')
        .toArray()
        .map((elem) => {
            const altText = $(elem).find('img').attr('alt');
            const link = $(elem).find('h5.feed-block-title a').attr('href');
            const price = $(elem).find('.z-highlight').text();
            const title = altText + ' ' + price;

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 product 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/product/:id triggers this guard 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/82e61cbb5b060a3d. Report an issue: GitHub.