DIYgod/RSSHub · warning

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

Error message

Bad category. See <a href="https://docs.rsshub.app/routes/government#wu-han-dong-hu-xin-ji-shu-kai-fa-qu">docs</a>

What it means

Thrown by the Wuhan East Lake High-Tech Zone (光谷) route (deprecated) when :caty is not in config (documented keys: tz 通知, gg 公告). Miss throws before the HTTP request.

Source

Thrown at lib/routes-deprecated/gov/wuhan/wehdz.js:22

const { parseDate } = require('@/utils/parse-date');

const root_url = 'http://www.wehdz.gov.cn/';

const config = {
    tz: {
        link: '/tzgg_53/tz/',
        title: '通知',
    },
    gg: {
        link: '/tzgg_53/gg/',
        title: '公告',
    },
};

module.exports = async (ctx) => {
    const cfg = config[ctx.params.caty];
    if (!cfg) {
        throw new Error('Bad category. See <a href="https://docs.rsshub.app/routes/government#wu-han-dong-hu-xin-ji-shu-kai-fa-qu">docs</a>');
    }

    const current_url = url.resolve(root_url, cfg.link);
    const response = await got({
        method: 'get',
        url: current_url,
    });

    const $ = cheerio.load(response.data);
    const list = $('ul.main-list li[class!=line]')
        .slice(0, 20)
        .map((_, item) => {
            item = $(item);
            const a = item.find('a[href]');
            const span = item.find('span');
            return {
                title: a.text(),
                link: url.resolve(current_url, a.attr('href')),

View on GitHub (pinned to bed535e087)

Solutions

  1. Use tz (通知) or gg (公告).
  2. Confirm against the config map at the top of lib/routes-deprecated/gov/wuhan/wehdz.js.
  3. Do not reuse slugs from sibling Wuhan routes.

Example fix

// before
GET /gov/wuhan/wehdz/gonggao   // not a key
// after
GET /gov/wuhan/wehdz/gg          // 公告
Defensive patterns

Strategy: validation

Validate before calling

const VALID = ['tz', 'gg'];
if (!VALID.includes(ctx.params.caty)) throw new Error(`Invalid caty. Valid: ${VALID.join(', ')}`);

Type guard

const isCaty = (v: string): v is 'tz' | 'gg' => ['tz', 'gg'].includes(v);

Try / catch

try { await fetch(route); }
catch (e) { if (/Bad category/.test(e.message)) showTzGg(); else throw e; }

Prevention

When it happens

Trigger: Request with a slug outside {tz, gg}, e.g. /gov/wuhan/wehdz/<unknown>.

Common situations: Slug typo or confusing this zone's slugs with the broader Wuhan kjj route slugs.

Related errors


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