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-shi-ke-xue-ji-shu-ju">docs</a>
What it means
Thrown by the Wuhan Science and Technology Bureau route (deprecated) when :caty is absent from the config map (documented keys include tzgg 通知公告, gsxx 公示信息). config[ctx.params.caty] undefined → throw before fetch.
Source
Thrown at lib/routes-deprecated/gov/wuhan/kjj.js:22
const { parseDate } = require('@/utils/parse-date');
const root_url = 'http://kjj.wuhan.gov.cn/';
const config = {
tzgg: {
link: '/wmfw/tzgg/tzgg_18371/',
title: '通知公告',
},
gsxx: {
link: '/wmfw/tzgg/gsxx/',
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-shi-ke-xue-ji-shu-ju">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.list_news li')
.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
- Use a documented slug such as tzgg or gsxx.
- Confirm keys against the config map at the top of lib/routes-deprecated/gov/wuhan/kjj.js.
- If the source page 404s, report the route as broken.
Example fix
// before GET /gov/wuhan/kjj/tongzhi // not a key // after GET /gov/wuhan/kjj/tzgg // 通知公告
Defensive patterns
Strategy: validation
Validate before calling
const VALID = ['tzgg', 'gsxx' /* see config in lib/routes-deprecated/gov/wuhan/kjj.js */];
if (!VALID.includes(ctx.params.caty)) throw new Error('Invalid caty'); Type guard
const isCaty = (v: string): v is 'tzgg' | 'gsxx' => ['tzgg', 'gsxx'].includes(v);
Try / catch
try { await fetch(route); }
catch (e) { if (/Bad category/.test(e.message)) listSlugs(); else throw e; } Prevention
- Don't confuse kjj (科技局) slugs with other Wuhan routes.
- Re-check the source page still resolves.
When it happens
Trigger: Request with a slug not in config, e.g. /gov/wuhan/kjj/<unknown>.
Common situations: Slug typo, or source portal restructure removing a section so its config entry was deleted.
Related errors
- Bad category. See <a href="https://docs.rsshub.app/routes/go
- 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
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/200447369b51ee50.
Report an issue: GitHub.