{"record":{"id":"46f9e8a67cdea51e","repo":"DIYgod/RSSHub","slug":"invalid-type-46f9e8","errorCode":null,"errorMessage":"invalid type","messagePattern":"invalid type","errorType":"validation","errorClass":"InvalidParameterError","httpStatus":null,"severity":"error","filePath":"lib/routes/ustc/math.ts","lineNumber":51,"sourceCode":"        {\n            source: ['math.ustc.edu.cn/'],\n            target: '/math',\n        },\n    ],\n    name: '数学科学学院',\n    maintainers: ['ne0-wu'],\n    handler,\n    url: 'math.ustc.edu.cn/',\n    description: `| 学院新闻 | 通知公告 | 学术交流 | 学术报告 |\n| -------- | -------- | -------- | -------- |\n| xyxw     | tzgg     | xsjl     | xsbg     |`,\n};\n\nasync function handler(ctx) {\n    const type = ctx.req.param('type') ?? 'tzgg';\n    const info = map.get(type);\n    if (!info) {\n        throw new InvalidParameterError('invalid type');\n    }\n    const id = info.id;\n\n    const response = await got(`${host}/${id}/list.htm`);\n    const $ = load(response.data);\n\n    let items = $('#wp_news_w6 > .wp_article_list > .list_item')\n        .toArray()\n        .map((item): DataItem => {\n            const elem = $(item);\n            const title = elem.find('.Article_Title > a').attr('title');\n            let link = elem.find('.Article_Title > a').attr('href');\n            link = link!.startsWith('/') ? host + link : link;\n            // Assume that the articles are published at 12:00 UTC+8\n            const pubDate = timezone(parseDate(elem.find('.Article_PublishDate').text(), 'YYYY-MM-DD'), -4);\n            return {\n                title: title!,\n                pubDate,","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/ustc/math.ts#L33-L69","documentation":"Thrown by the USTC math school route when the `type` path parameter is not found in the internal `map` of valid types. The valid types are `xyxw` (学院新闻), `tzgg` (通知公告), `xsjl` (学术交流), and `xsbg` (学术报告). This is an `InvalidParameterError`, which RSSHub maps to an HTTP 400 response, making it a user-facing validation error rather than a server crash.","triggerScenarios":"A request to `/ustc/math/:type` where `:type` is not one of `xyxw`, `tzgg`, `xsjl`, or `xsbg`. For example `/ustc/math/news` or `/ustc/math/XSZW`. The parameter defaults to `tzgg` when omitted, so only an explicitly wrong value triggers it.","commonSituations":"Typo in the type parameter, using an English word instead of the pinyin abbreviation, or an outdated bookmark pointing to a type code that was renamed or removed.","solutions":["Use one of the four valid type codes: `xyxw`, `tzgg`, `xsjl`, or `xsbg`.","Omit the type segment to use the default `tzgg`: `/ustc/math`.","Check the route description table in the route metadata for the current valid codes."],"exampleFix":"// before\nGET /ustc/math/news\n// after\nGET /ustc/math/tzgg","handlingStrategy":"validation","validationCode":"const VALID_TYPES = ['xyxw', 'tzgg', 'xsjl', 'xsbg'];\nif (!VALID_TYPES.includes(type)) {\n    throw new InvalidParameterError(`Invalid type: ${type}. Valid types: ${VALID_TYPES.join(', ')}`);\n}","typeGuard":"function isValidMathType(type: string): type is 'xyxw' | 'tzgg' | 'xsjl' | 'xsbg' {\n    return ['xyxw', 'tzgg', 'xsjl', 'xsbg'].includes(type);\n}","tryCatchPattern":null,"preventionTips":["Always check the route's description table for valid type codes before subscribing.","URL-encode type parameters to avoid silent character corruption.","The existing Map-based lookup is good practice — extend it by including valid values in the error message."],"tags":["parameter-validation","invalid-parameter","ustc","rss-route","map-lookup"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}