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#bei-jing-shi-wei-sheng-jian-kang-wei-yuan-hui">docs</a>
What it means
Thrown by the Beijing Municipal Health Commission route (deprecated) when the requested category key is not present in the route's static config map. The handler indexes config with ctx.params.caty and, on a miss, throws a plain Error whose message links to the route's documentation anchor. It is a parameter-validation guard that runs before any network request.
Source
Thrown at lib/routes-deprecated/gov/beijing/mhc.js:29
},
jcdt: {
link: '/xwzx_20031/jcdt/',
title: '基层动态',
},
mtjj: {
link: '/xwzx_20031/mtjj/',
title: '媒体聚焦',
},
rdxws: {
link: '/xwzx_20031/rdxws/',
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#bei-jing-shi-wei-sheng-jian-kang-wei-yuan-hui">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 = $('div.weinei_left_con div.weinei_left_con_line')
.slice(0, 10)
.map((_, item) => {
item = $(item);
const a = item.find('a[title]');
return {
title: a.text(),
link: url.resolve(current_url, a.attr('href')),
pubDate: new Date(item.find('div.weinei_left_con_line_date').text() + ' GMT+8').toUTCString(),
};View on GitHub (pinned to bed535e087)
Solutions
- Open the docs anchor in the error message and copy a documented category slug exactly (e.g. mtjj, rdxws).
- Inspect the config object at the top of lib/routes-deprecated/gov/beijing/mhc.js to list the currently accepted keys.
- Migrate off the deprecated route; if no replacement exists, open an issue against RSSHub rather than guessing slugs.
Example fix
// before GET /gov/beijing/mhc/mtjjj // typo // after GET /gov/beijing/mhc/mtjj // 媒体聚焦
Defensive patterns
Strategy: validation
Validate before calling
const VALID = ['mtjj', 'rdxws' /* see config in lib/routes-deprecated/gov/beijing/mhc.js */];
const caty = ctx.params.caty;
if (!VALID.includes(caty)) {
// surface your own 400 instead of relying on the route's generic Error
throw new Error(`Invalid caty '${caty}'. Valid: ${VALID.join(', ')}`);
} Type guard
const isCaty = (v: string): v is 'mtjj' | 'rdxws' => ['mtjj', 'rdxws'].includes(v);
Try / catch
try { await rsshub('/gov/beijing/mhc/' + caty); }
catch (e) {
if (/Bad category/.test(e.message)) { /* prompt user for a valid slug */ }
else throw e;
} Prevention
- Source the slug list from the route's config object, not from memory.
- Treat deprecated routes as unstable — pin or migrate.
When it happens
Trigger: A GET to the RSSHub route with a :caty path segment whose value is not a key of the config object (e.g. /gov/beijing/mhc/<unknown>). The lookup config[ctx.params.caty] returns undefined and the throw fires.
Common situations: Typo in the category slug, copying a category from an outdated doc/README, or hitting the route after the source site reorganized sections and the route config was pruned. Deprecated routes under lib/routes-deprecated often have stale slugs.
Related errors
- Bad category. See <a href="https://docs.rsshub.app/routes/go
- Nanjing, Cannot find page
- Bad category. See <a href="https://docs.rsshub.app/routes/go
- Bad category. See <a href="https://docs.rsshub.app/routes/go
- Bad category. See <a href="https://docs.rsshub.app/routes/go
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/612442b34c0b0e71.
Report an issue: GitHub.