{"record":{"id":"19e989d0492a2b7b","repo":"DIYgod/RSSHub","slug":"unknown-category-ctx-req-param-category","errorCode":null,"errorMessage":"Unknown category: ${ctx.req.param('category')}","messagePattern":"Unknown category: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/routes/gov/maonan/maonan.ts","lineNumber":103,"sourceCode":"            break;\n        case 'zdhy':\n            id = 'zwxw/zdhy';\n            name = '重大会议';\n            break;\n        case 'tzgg':\n            id = 'zwgk/tzgg';\n            name = '公告公示';\n            break;\n        case 'zlxx':\n            id = 'zwgk/zlxx';\n            name = '招录信息';\n            break;\n        case 'zcjd':\n            id = 'zwgk/zcjd';\n            name = '政策解读';\n            break;\n        default:\n            throw new Error(`Unknown category: ${ctx.req.param('category')}`);\n    }\n\n    const res = await got(`${host}/${id}/`);\n    const dataArray = res.data;\n    const $ = load(dataArray);\n    const list = $('li.clearfix a[href*=\"www.maonan.gov.cn\"], li.clearfix a[href*=\"mp.weixin.qq.com\"]');\n\n    const items = await Promise.all(\n        list.map((i, item) => {\n            const $item = $(item);\n\n            const url = new URL($item.attr('href')!);\n            const link = url.href;\n\n            const pubDate = timezone(parseDate($('a[href=\"' + link + '\"] ~ .time').text()), 8);\n\n            return cache.tryGet(link, async () => {\n                // 获取网页","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/gov/maonan/maonan.ts#L85-L121","documentation":"Thrown by the Maonan district government route in the default case of a switch statement on the ':category' path parameter. Seven valid categories are defined: zwgk, zwxw, mndt, zdhy, tzgg, zlxx, zcjd. Each maps to a specific path on www.maonan.gov.cn.","triggerScenarios":"A request to /gov/maonan/:category where the category is not one of the seven valid values. The switch maps each category to an id path and display name; the default throws with the invalid category value.","commonSituations":"Typo in category (e.g., 'zwg' instead of 'zwgk'); using a category name instead of its code (e.g., '公告公示' instead of 'tzgg'); category was removed or renamed.","solutions":["Use one of the seven valid category codes: zwgk, zwxw, mndt, zdhy, tzgg, zlxx, zcjd","Refer to the route description table for the category-to-code mapping","Use the documented example: /gov/maonan/zwgk"],"exampleFix":"// before\ndefault:\n    throw new Error(`Unknown category: ${ctx.req.param('category')}`);\n\n// after (use InvalidParameterError for RSSHub consistency)\nimport InvalidParameterError from '@/errors/types/invalid-parameter';\n// ...\ndefault:\n    throw new InvalidParameterError(`Unknown category '${ctx.req.param('category')}'. Valid: zwgk, zwxw, mndt, zdhy, tzgg, zlxx, zcjd`);","handlingStrategy":"validation","validationCode":"const VALID_CATEGORIES = ['zwgk', 'zwxw', 'mndt', 'zdhy', 'tzgg', 'zlxx', 'zcjd'];\nconst category = ctx.req.param('category');\nif (!VALID_CATEGORIES.includes(category)) {\n    throw new InvalidParameterError(`Unknown category '${category}'. Valid: ${VALID_CATEGORIES.join(', ')}`);\n}","typeGuard":"function isValidCategory(cat: string): cat is 'zwgk' | 'zwxw' | 'mndt' | 'zdhy' | 'tzgg' | 'zlxx' | 'zcjd' {\n    return ['zwgk', 'zwxw', 'mndt', 'zdhy', 'tzgg', 'zlxx', 'zcjd'].includes(cat);\n}","tryCatchPattern":null,"preventionTips":["Use the category code, not the Chinese display name","Refer to the route description table for valid codes","Use the documented example: /gov/maonan/zwgk"],"tags":["validation","parameter","invalid-parameter","government"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}