{"record":{"id":"da2d78ebd56519db","repo":"DIYgod/RSSHub","slug":"typeparam","errorCode":null,"errorMessage":"通知类型${typeParam}未定义","messagePattern":"通知类型(.+?)未定义","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/routes/gdut/oa-news.ts","lineNumber":87,"sourceCode":"    maintainers: ['jim-kirisame', 'GamerNoTitle', 'Richard-Zheng'],\n    handler,\n    url: 'oas.gdut.edu.cn/seeyon',\n    description: `学校可能会因为 IP 来源非学校而做出一定的限制，建议在校内网络环境下使用 RSS 阅读器订阅。\n\n| 类型     | 参数           | 可能需要校内访问 |\n| -------- | -------------- | ---------------- |\n| 部处简讯 | department     | 是               |\n| 学院简讯 | academy        | 是               |\n| 校内通知 | notice         | 是               |\n| 公示公告 | announcement   | 是               |\n| 招标结果 | tender\\\\_result | 否               |\n| 招标公告 | tender\\\\_invite | 否               |`,\n};\n\nasync function handler(ctx) {\n    const typeParam = ctx.req.param('type') ?? 'notice';\n    if (typeMap[typeParam] === undefined) {\n        throw new Error('通知类型' + typeParam + '未定义');\n    }\n\n    const type = typeMap[typeParam];\n\n    // 获取cookie\n    const cookieJar = new CookieJar();\n    await got(site + '/ggIP.do?method=portalSeachMore&subject=&departmentName=&newsType=&startDate=&endDate=', {\n        cookieJar,\n    });\n\n    // 获取文章列表\n    const listUrl = '/ajax.do?method=ajaxAction&managerName=ggManager&rnd=1';\n    const resp = await got.post(site + listUrl, {\n        cookieJar,\n        form: {\n            managerMethod: 'kkFindListDatas',\n            arguments: getArg(type),\n        },","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/gdut/oa-news.ts#L69-L105","documentation":"Thrown by the GDUT OA (Office Automation) news route when the ':type' path parameter does not match any key in the hardcoded typeMap object. The typeMap defines exactly six valid keys: department, academy, notice, announcement, tender_result, tender_invite. The error message includes the invalid type value to aid debugging.","triggerScenarios":"A request to /gdut/oa_news/<type> where <type> is not one of the six valid keys (e.g., /gdut/oa_news/news, /gdut/oa_news/undefined). The default is 'notice' when no type is provided (ctx.req.param('type') ?? 'notice'), so this only fires when an explicit invalid value is supplied.","commonSituations":"Typos in the route URL (e.g., 'tendor_result' instead of 'tender_result'); copying an example URL and forgetting to replace a placeholder; using a category name from documentation that changed between versions.","solutions":["Use one of the six valid type values: department, academy, notice, announcement, tender_result, tender_invite","Omit the type parameter entirely to default to 'notice'","Refer to the route description table in the source code for the complete mapping"],"exampleFix":"// before\nconst typeParam = ctx.req.param('type') ?? 'notice';\nif (typeMap[typeParam] === undefined) {\n    throw new Error('通知类型' + typeParam + '未定义');\n}\n\n// after (use InvalidParameterError for consistency with RSSHub conventions)\nimport InvalidParameterError from '@/errors/types/invalid-parameter';\n// ...\nif (typeMap[typeParam] === undefined) {\n    throw new InvalidParameterError(`Invalid type '${typeParam}'. Valid types: ${Object.keys(typeMap).join(', ')}`);\n}","handlingStrategy":"validation","validationCode":"const VALID_TYPES = ['department', 'academy', 'notice', 'announcement', 'tender_result', 'tender_invite'];\nconst typeParam = ctx.req.param('type') ?? 'notice';\nif (!VALID_TYPES.includes(typeParam)) {\n    // Return 400 before hitting the handler, or surface a helpful message\n    throw new InvalidParameterError(`Invalid type '${typeParam}'. Valid: ${VALID_TYPES.join(', ')}`);\n}","typeGuard":"function isValidType(type: string): type is keyof typeof typeMap {\n    return Object.hasOwn(typeMap, type);\n}","tryCatchPattern":null,"preventionTips":["Always reference the typeMap keys when constructing URLs","Use the default ('notice') when unsure","Add a route-level middleware that validates path params against known option lists"],"tags":["validation","parameter","invalid-parameter"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}