{"record":{"id":"08393b6e59b45215","repo":"DIYgod/RSSHub","slug":"bad-category-see-a-href-https-docs-rsshub-app-08393b","errorCode":null,"errorMessage":"Bad category. See <a href=\"https://docs.rsshub.app/routes/government#guang-dong-sheng-ren-min-zheng-fu-shen-zhen-shi-zhu-fang-he-jian-she-ju\">docs</a>","messagePattern":"Bad category\\. See <a href=\"https://docs\\.rsshub\\.app/routes/government#guang-dong-sheng-ren-min-zheng-fu-shen-zhen-shi-zhu-fang-he-jian-she-ju\">docs</a>","errorType":"validation","errorClass":"InvalidParameterError","httpStatus":null,"severity":"warning","filePath":"lib/routes/gov/shenzhen/zjj/index.ts","lineNumber":46,"sourceCode":"    },\n    radar: [\n        {\n            source: ['zjj.sz.gov.cn/xxgk/:caty'],\n        },\n    ],\n    name: '住房和建设局',\n    maintainers: ['lonn'],\n    handler,\n    description: `| 通知公告 |\n| :------: |\n|   tzgg   |`,\n};\n\nasync function handler(ctx) {\n    const baseUrl = 'http://zjj.sz.gov.cn/xxgk/';\n    const cfg = config[ctx.req.param('caty')];\n    if (!cfg) {\n        throw new InvalidParameterError('Bad category. See <a href=\"https://docs.rsshub.app/routes/government#guang-dong-sheng-ren-min-zheng-fu-shen-zhen-shi-zhu-fang-he-jian-she-ju\">docs</a>');\n    }\n\n    const currentUrl = new URL(cfg.link, baseUrl).href;\n\n    const { data: response } = await got(currentUrl);\n    const $ = load(response);\n\n    const items = $('div.listcontent_right ul li')\n        // 使用“toArray()”方法将选择的所有 DOM 元素以数组的形式返回。\n        .toArray()\n        // 使用“map()”方法遍历数组，并从每个元素中解析需要的数据。\n        .map((item) => {\n            const $item = $(item);\n            const a = $item.find('a');\n            return {\n                title: a.text(),\n                // `link` 需要一个绝对 URL，但 `a.attr('href')` 返回一个相对 URL。\n                link: a.attr('href'),","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/gov/shenzhen/zjj/index.ts#L28-L64","documentation":"Thrown by RSSHub's Shenzhen Housing and Construction Bureau route handler when the `:caty` path parameter does not match any key in the local `config` object. The `config` object at lib/routes/gov/shenzhen/zjj/index.ts:9 defines exactly one entry: `tzgg` (通知公告). RSSHub's `InvalidParameterError` serializes to an HTTP 400 response and renders the message as HTML, which is why the message contains an `<a>` tag linking to the docs.","triggerScenarios":"Requesting `/gov/shenzhen/zjj/xxgk/<value>` where `<value>` is anything other than `tzgg`. The handler does `config[ctx.req.param('caty')]` and any missing key yields `undefined`, tripping the guard at line 45.","commonSituations":"User copies a category slug from a sibling Shenzhen gov sub-route (e.g. zzb's `rqgs`, `zcfg`, `gzdt`), mistypes the category, or follows outdated documentation listing categories that were removed or never added. The route description table only shows `tzgg`.","solutions":["Use `/gov/shenzhen/zjj/xxgk/tzgg` — it is the sole valid category.","If additional categories are needed, confirm the corresponding sub-page exists under `zjj.sz.gov.cn/xxgk/`, then add an entry to the `config` object with the correct relative `link` path and `title`."],"exampleFix":"// before (broken URL)\n// GET /gov/shenzhen/zjj/xxgk/notice\n\n// after (correct URL)\n// GET /gov/shenzhen/zjj/xxgk/tzgg","handlingStrategy":"validation","validationCode":"const VALID_CATEGORIES = ['tzgg'] as const;\nfunction validateCategory(caty: string | undefined): caty is typeof VALID_CATEGORIES[number] {\n    return (VALID_CATEGORIES as readonly string[]).includes(caty ?? '');\n}\n// Usage in handler:\n// if (!validateCategory(ctx.req.param('caty'))) {\n//     throw new InvalidParameterError(`Bad category. Valid: ${VALID_CATEGORIES.join(', ')}`);\n// }","typeGuard":"function isValidZjjCategory(caty: string): caty is 'tzgg' {\n    return caty === 'tzgg';\n}","tryCatchPattern":null,"preventionTips":["Document the single valid value (`tzgg`) prominently in the route description.","Consider using route-level regex constraints (e.g. `/zjj/xxgk/:caty(tzgg)`) to reject invalid values before they reach the handler.","Keep the config object and the description table in sync when adding or removing categories."],"tags":["parameter-validation","user-input","rsshub","government"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}