DIYgod/RSSHub · error · InvalidParameterError

This category does not exist. Please refer to the documentat

Error message

This category does not exist. Please refer to the documentation for the correct usage.

What it means

The 36kr hot-list route accepts a fixed set of category keys (24, renqi, zonghe, shoucang). Object.hasOwn(categories, category) rejects anything else before the route requests the hot-list page or its WAF-guarded API.

Source

Thrown at lib/routes/36kr/hot-list.ts:67

    description: `| 24 小时热榜 | 资讯人气榜 | 资讯综合榜 | 资讯收藏榜 |
| ----------- | ---------- | ---------- | ---------- |
| 24          | renqi      | zonghe     | shoucang   |`,
};

const getProperty = (object, key) => {
    let result = object;
    const keys = key.split('.');
    for (const k of keys) {
        result &&= result[k];
    }
    return result;
};

async function handler(ctx) {
    const category = ctx.req.param('category') ?? '24';

    if (!Object.hasOwn(categories, category)) {
        throw new InvalidParameterError('This category does not exist. Please refer to the documentation for the correct usage.');
    }

    const currentUrl = category === '24' ? rootUrl : `${rootUrl}/hot-list/catalog`;

    const wafTokenId = await getWafTokenId();
    const response = await got({
        method: 'get',
        url: currentUrl,
        headers: {
            Cookie: `_waftokenid=${wafTokenId}`,
        },
    });

    const data = getProperty(JSON.parse(response.data.match(/window.initialState=(\{.*\})/)[1]), categories[category].key);

    let items = data
        .slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 10)
        .filter((item) => item.itemType !== 0)

View on GitHub (pinned to bed535e087)

Solutions

  1. Use one of the literal keys: 24, renqi, zonghe, shoucang.
  2. Omit the segment to default to '24' (24-hour hot list).

Example fix

// before
/36kr/hot-list/2          // ordinal, not the slug
// after
/36kr/hot-list/renqi
Defensive patterns

Strategy: validation

Validate before calling

const CATEGORIES_36KR = new Set(['24', 'renqi', 'zonghe', 'shoucang']);
function valid36krCategory(c) {
  return CATEGORIES_36KR.has(String(c));
}

Type guard

function is36krCategory(c): c is '24'|'renqi'|'zonghe'|'shoucang' {
  return ['24','renqi','zonghe','shoucang'].includes(c);
}

Prevention

When it happens

Trigger: Calling /36kr/hot-list/:category with a value outside {24, renqi, zonghe, shoucang} — e.g. using the numeric position '1/2/3/4', a trailing slash, or wrong case.

Common situations: Confusing the ordinal column number with the slug; trailing slash producing an empty string; case mismatch ('Renqi' vs 'renqi').

Related errors


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