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#zhong-qing-shi-ren-min-zheng-fu-liang-jiang-xin-qu-xin-xi-gong-kai-wang-zheng-wu-gong-kai">docs</a>
What it means
Thrown by the Chongqing Liangjiang New Area government-affairs-publicity route (deprecated) when the :caty segment is absent from the config map. The handler resolves a URL from config[ctx.params.caty]; a miss throws a plain Error pointing at the docs anchor. No fetch occurs before the check.
Source
Thrown at lib/routes-deprecated/gov/chongqing/ljxq/zwgk.js:21
const cheerio = require('cheerio');
const rootUrl = 'http://ljxq.cq.gov.cn';
const config = {
lzyj: {
link: '/zwgk_199/fdzdgknr/zcwj/',
title: '履职依据',
},
gsgg: {
link: '/zwgk_199/fdzdgknr/gggs/',
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#zhong-qing-shi-ren-min-zheng-fu-liang-jiang-xin-qu-xin-xi-gong-kai-wang-zheng-wu-gong-kai">docs</a>');
}
const currentUrl = url.resolve(rootUrl, cfg.link);
const response = await got({
method: 'get',
url: currentUrl,
});
const $ = cheerio.load(response.data);
$('tr.cwx-tit').remove();
const list = $('table.cwx-table tbody tr')
.slice(0, 10)
.map((_, item) => {
item = $(item);
const a = item.find('a');
return {View on GitHub (pinned to bed535e087)
Solutions
- Use a documented slug such as zcwj (履职依据) or gsgg (公示公告).
- Read the config map at the top of lib/routes-deprecated/gov/chongqing/ljxq/zwgk.js for the authoritative key list.
- Prefer a non-deprecated equivalent route if one exists.
Example fix
// before GET /gov/chongqing/ljxq/zwgk/zwwj // wrong slug // after GET /gov/chongqing/ljxq/zwgk/zcwj // 履职依据
Defensive patterns
Strategy: validation
Validate before calling
const VALID = ['zcwj', 'gsgg' /* + see config in lib/routes-deprecated/gov/chongqing/ljxq/zwgk.js */];
if (!VALID.includes(ctx.params.caty)) throw new Error('Invalid caty'); Type guard
const isCaty = (v: string): v is 'zcwj' | 'gsgg' => ['zcwj', 'gsgg'].includes(v);
Try / catch
try { await fetch(route); }
catch (e) { if (/Bad category/.test(e.message)) handleInvalidSlug(); else throw e; } Prevention
- Keep a per-route allowlist near the UI that builds the URL.
- Validate before constructing the path.
When it happens
Trigger: Requesting the route with a category slug not defined in config (e.g. zcwjy, gggs misspelled). config[ctx.params.caty] is undefined and the throw executes.
Common situations: Slug typo, using a category from a sibling Chongqing route that does not apply here, or stale docs after a site restructure of the Liangjiang portal.
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/f8a9e815ebb27b7a.
Report an issue: GitHub.