DIYgod/RSSHub · error · InvalidParameterError

Bad category. See <a href="https://docs.rsshub.app/routes/ne

Error message

Bad category. See <a href="https://docs.rsshub.app/routes/new-media#it-zhi-jia">https://docs.rsshub.app/routes/new-media#it-zhi-jia</a>

What it means

Thrown by the IT之家 (ithome) category-news route as `InvalidParameterError` when `ctx.req.param('caty')` is not a key in the route's `config` map. Valid categories are `it`, `soft`, `win10`, `win11`, `iphone`, `ipad`, `android`, `digi`, `next`.

Source

Thrown at lib/routes/ithome/index.ts:64

        requireConfig: false,
        requirePuppeteer: false,
        antiCrawler: false,
        supportBT: false,
        supportPodcast: false,
        supportScihub: false,
    },
    name: '分类资讯',
    maintainers: ['luyuhuang'],
    handler,
    description: `| it      | soft     | win10      | win11      | iphone      | ipad      | android      | digi     | next     |
| ------- | -------- | ---------- | ---------- | ----------- | --------- | ------------ | -------- | -------- |
| IT 资讯 | 软件之家 | win10 之家 | win11 之家 | iphone 之家 | ipad 之家 | android 之家 | 数码之家 | 智能时代 |`,
};

async function handler(ctx) {
    const cfg = config[ctx.req.param('caty')];
    if (!cfg) {
        throw new InvalidParameterError('Bad category. See <a href="https://docs.rsshub.app/routes/new-media#it-zhi-jia">https://docs.rsshub.app/routes/new-media#it-zhi-jia</a>');
    }

    const current_url = get_url(ctx.req.param('caty'));
    const response = await got({
        method: 'get',
        url: current_url,
    });

    const $ = load(response.data);
    const list = $('#list > div.fl > ul > li > div > h2 > a')
        .slice(0, 10)
        .toArray()
        .map((item): DataItem => {
            const $item = $(item);
            return {
                title: $item.text(),
                link: $item.attr('href'),
            };

View on GitHub (pinned to bed535e087)

Solutions

  1. Use one of the documented keys: `/ithome/it`, `/ithome/soft`, `/ithome/win10`, `/ithome/win11`, `/ithome/iphone`, `/ithome/ipad`, `/ithome/android`, `/ithome/digi`, `/ithome/next`.
  2. If a new category is needed, add it to the `config` map in lib/routes/ithome/index.ts with its URL builder.

Example fix

// before: /ithome/news
// after:  /ithome/it
Defensive patterns

Strategy: validation

Validate before calling

const cfg = config[ctx.req.param('caty')];
if (!cfg) throw new InvalidParameterError(`Bad category. Valid: ${Object.keys(config).join(', ')}`);

Type guard

const isKnownCategory = (c: string): c is keyof typeof config => c in config;

Prevention

When it happens

Trigger: Request to `/ithome/:caty` with a category not in the config map — e.g. `/ithome/news`, `/ithome/hardware`, a typo, or a Chinese display name instead of the English key.

Common situations: User passes the Chinese display name instead of the English key; outdated docs referencing a removed category; typo.

Related errors


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