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#guang-dong-sheng-jiao-yu-ting">docs</a>
What it means
Thrown by the Guangdong Provincial Education Department route (deprecated) when :caty is not a config key. The handler reads config[ctx.params.caty]; on undefined it throws a plain Error linking to the docs anchor before any HTTP request.
Source
Thrown at lib/routes-deprecated/gov/guangdong/edu.js:45
},
jydt: {
link: '/zxzx/jydt/',
title: '教育动态',
},
tpxw: {
link: '/zxzx/tpxw/',
title: '图片新闻',
},
zscd: {
link: '/zxzx/tzgg/',
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#guang-dong-sheng-jiao-yu-ting">docs</a>');
}
const currentUrl = url.resolve(rootUrl, cfg.link);
const response = await got({ method: 'get', url: currentUrl });
const $ = cheerio.load(response.data);
const list = $('div.list_list ul li')
.map((_, item) => {
item = $(item).find('a');
return {
title: item.text(),
link: item.attr('href'),
};
})
.get();
const items = await Promise.all(
list.map((item) =>View on GitHub (pinned to bed535e087)
Solutions
- Use a documented slug such as tpxw or zscd.
- Read the config map at the top of lib/routes-deprecated/gov/guangdong/edu.js for accepted keys.
- Move to a maintained route if the deprecated one is broken.
Example fix
// before GET /gov/guangdong/edu/tpuxw // typo // after GET /gov/guangdong/edu/tpxw // 图片新闻
Defensive patterns
Strategy: validation
Validate before calling
const VALID = ['tpxw', 'zscd' /* see config in lib/routes-deprecated/gov/guangdong/edu.js */];
if (!VALID.includes(ctx.params.caty)) throw new Error('Invalid caty'); Type guard
const isCaty = (v: string): v is 'tpxw' | 'zscd' => ['tpxw', 'zscd'].includes(v);
Try / catch
try { await fetch(route); }
catch (e) { if (/Bad category/.test(e.message)) promptForSlug(); else throw e; } Prevention
- Do not reuse slugs from sibling Guangdong routes.
- Validate slugs at the API boundary.
When it happens
Trigger: Request with a :caty not in the config map (documented slugs include tpxw 图片新闻 and zscd 政声传递). Miss throws immediately.
Common situations: Slug typo, stale docs, or the source portal renaming sections so a previously valid slug was removed from config.
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/6dd9b04543d34cc9.
Report an issue: GitHub.