{"record":{"id":"f8a9e815ebb27b7a","repo":"DIYgod/RSSHub","slug":"bad-category-see-a-href-https-docs-rsshub-app-f8a9e8","errorCode":null,"errorMessage":"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>","messagePattern":"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>","errorType":"exception","errorClass":null,"httpStatus":503,"severity":"warning","filePath":"lib/routes-deprecated/gov/chongqing/ljxq/zwgk.js","lineNumber":21,"sourceCode":"const cheerio = require('cheerio');\n\nconst rootUrl = 'http://ljxq.cq.gov.cn';\n\nconst config = {\n    lzyj: {\n        link: '/zwgk_199/fdzdgknr/zcwj/',\n        title: '履职依据',\n    },\n    gsgg: {\n        link: '/zwgk_199/fdzdgknr/gggs/',\n        title: '公示公告',\n    },\n};\n\nmodule.exports = async (ctx) => {\n    const cfg = config[ctx.params.caty];\n    if (!cfg) {\n        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>');\n    }\n\n    const currentUrl = url.resolve(rootUrl, cfg.link);\n    const response = await got({\n        method: 'get',\n        url: currentUrl,\n    });\n    const $ = cheerio.load(response.data);\n\n    $('tr.cwx-tit').remove();\n\n    const list = $('table.cwx-table tbody tr')\n        .slice(0, 10)\n        .map((_, item) => {\n            item = $(item);\n            const a = item.find('a');\n\n            return {","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes-deprecated/gov/chongqing/ljxq/zwgk.js#L3-L39","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nGET /gov/chongqing/ljxq/zwgk/zwwj   // wrong slug\n// after\nGET /gov/chongqing/ljxq/zwgk/zcwj    // 履职依据","handlingStrategy":"validation","validationCode":"const VALID = ['zcwj', 'gsgg' /* + see config in lib/routes-deprecated/gov/chongqing/ljxq/zwgk.js */];\nif (!VALID.includes(ctx.params.caty)) throw new Error('Invalid caty');","typeGuard":"const isCaty = (v: string): v is 'zcwj' | 'gsgg' => ['zcwj', 'gsgg'].includes(v);","tryCatchPattern":"try { await fetch(route); }\ncatch (e) { if (/Bad category/.test(e.message)) handleInvalidSlug(); else throw e; }","preventionTips":["Keep a per-route allowlist near the UI that builds the URL.","Validate before constructing the path."],"tags":["rsshub","parameter-validation","deprecated-route","government"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}