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-ren-min-zheng-fu-guang-dong-sheng-jiao-yu-kao-shi-yuan">docs</a>
What it means
Thrown by the Guangdong Education Examinations Authority route (deprecated) when :caty is missing from the config map. Accepted keys: shks, zkgs, bkzn, ywdt, gkzl, zcwj, zcjd. config[ctx.params.caty] returns undefined → throw before fetch.
Source
Thrown at lib/routes-deprecated/gov/guangdong/eea.js:22
const timezone = require('@/utils/timezone');
const { parseDate } = require('@/utils/parse-date');
const rootUrl = 'http://eea.gd.gov.cn/';
const config = {
kszs: { link: '/bmbk/kszs/', title: '考试招生' },
shks: { link: '/shks/', title: '社会考试' },
zkgs: { link: '/zwgk_zkgs/', title: '招考公示' },
bkzn: { link: '/bmbk/bkzn/', title: '报考指南' },
ywdt: { link: '/news/', title: '要闻动态' },
gkzl: { link: '/zwgk/gkzl/', title: '公开专栏' },
zcwj: { link: '/zwgk/zwwj/', title: '政策文件' },
zcjd: { link: '/zcjd/', 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-ren-min-zheng-fu-guang-dong-sheng-jiao-yu-kao-shi-yuan">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.main>div.content>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 one of shks, zkgs, bkzn, ywdt, gkzl, zcwj, zcjd.
- Confirm against the config map at the top of lib/routes-deprecated/gov/guangdong/eea.js.
- Avoid mixing slugs between eea.js and edu.js — they are different sites.
Example fix
// before GET /gov/guangdong/eea/zwwj // typo (config has zcwj) // after GET /gov/guangdong/eea/zcwj // 政策文件
Defensive patterns
Strategy: validation
Validate before calling
const VALID = ['shks', 'zkgs', 'bkzn', 'ywdt', 'gkzl', 'zcwj', 'zcjd'];
if (!VALID.includes(ctx.params.caty)) throw new Error(`Invalid caty. Valid: ${VALID.join(', ')}`); Type guard
type EeaCaty = 'shks' | 'zkgs' | 'bkzn' | 'ywdt' | 'gkzl' | 'zcwj' | 'zcjd'; const isEeaCaty = (v: string): v is EeaCaty => (['shks','zkgs','bkzn','ywdt','gkzl','zcwj','zcjd'] as string[]).includes(v);
Try / catch
try { await fetch(route); }
catch (e) { if (/Bad category/.test(e.message)) showValidList(); else throw e; } Prevention
- Distinguish eea (考试院) slugs from edu (教育厅) slugs.
- Keep the seven-key allowlist in sync with config.
When it happens
Trigger: Request with a slug outside the seven valid keys, e.g. /gov/guangdong/eea/<unknown>.
Common situations: Slug typo; confusing this authority's slugs with the Education Department's (edu.js) slugs which look similar but differ.
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/d26637261f5b049d.
Report an issue: GitHub.