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 good-articles-by-category route (/smzdm/haowen/fenlei/:name). The route scrapes post.smzdm.com/fenlei/:name which requires a cookie for the anti-crawler protection. The error message '排行榜' (rankings) is a copy-paste artifact — this route fetches categorized good-articles, not rankings.

Source

Thrown at lib/routes/smzdm/haowen-fenlei.ts:47

        supportScihub: false,
    },
    radar: [
        {
            source: ['post.smzdm.com/fenlei/:name'],
            target: '/haowen/fenlei/:name',
        },
    ],
    name: '好文分类',
    maintainers: ['LogicJake'],
    handler,
    description: `| 最新 | 周排行 | 月排行 |
| ---- | ------ | ------ |
| 0    | 7      | 30     |`,
};

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

    const name = ctx.req.param('name');
    const sort = ctx.req.param('sort') || '0';

    const link = sort === '0' ? `https://post.smzdm.com/fenlei/${name}/` : `https://post.smzdm.com/fenlei/${name}/hot_${sort}/`;

    const response = await got.get(link, {
        headers: getHeaders(),
    });
    const $ = load(response.data);
    const title = $('div.crumbs.nav-crumbs').text().split('>').pop();

    const list = $('div.list.post-list')
        .toArray()
        .map((item) => {
            const $item = $(item);
            return {

View on GitHub (pinned to bed535e087)

Solutions

  1. Set SMZDM_COOKIE with a valid session cookie from a logged-in smzdm.com browser 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 good-articles category 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/haowen/fenlei/:name 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/d81e910b4e77c76e. Report an issue: GitHub.