{"record":{"id":"a1e35476a0ab3639","repo":"DIYgod/RSSHub","slug":"invalid-keyid","errorCode":null,"errorMessage":"invalid keyId","messagePattern":"invalid keyId","errorType":"validation","errorClass":"InvalidParameterError","httpStatus":400,"severity":"warning","filePath":"lib/routes/nudt/yjszs.ts","lineNumber":64,"sourceCode":"    radar: [\n        {\n            source: ['yjszs.nudt.edu.cn'],\n        },\n    ],\n    name: '研究生院',\n    maintainers: ['Blank0120'],\n    handler,\n    url: 'yjszs.nudt.edu.cn/',\n    description: `| 通知公告 | 首页 | 招生简章 | 学校政策 | 硕士招生 | 博士招生 | 院所发文 | 数据统计 |\n| -------- | ---- | -------- | -------- | -------- | -------- | -------- | -------- |\n| 2        | 1    | 8        | 12       | 16       | 17       | 23       | 25       |`,\n};\n\nasync function handler(ctx) {\n    const keyId = ctx.req.param('keyId') ?? '2';\n    const info = yjszs.get(keyId);\n    if (!info) {\n        throw new InvalidParameterError('invalid keyId');\n    }\n    let link = `${host}/pubweb/homePageList`;\n    link += keyId === '2' ? '/searchContent.view' : `/recruitStudents.view?keyId=${keyId}`;\n    const response = await got({\n        method: 'get',\n        url: link,\n    });\n\n    const $ = load(response.data);\n    const content = $('.news-list li');\n    const items = content.toArray().map((elem) => {\n        const $elem = $(elem);\n        return {\n            link: new URL($elem.find('a').attr('href')!, host).href,\n            title: $elem.find('h3').text().trim(),\n            pubDate: timezone(parseDate($elem.find('.time').text(), 'YYYY-MM-DD'), -8),\n        };\n    });","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/nudt/yjszs.ts#L46-L82","documentation":"Thrown as an `InvalidParameterError` when the `keyId` path parameter for the NUDT (National University of Defense Technology) graduate admissions route is not found in the `yjszs` Map. Valid keyIds are: '1', '2', '8', '12', '16', '17', '23', '25'. The handler defaults to '2' if no parameter is provided.","triggerScenarios":"Requesting `/nudt/yjszs/<keyId>` with a keyId that is not in the hardcoded Map (e.g., '3', '99', 'abc'). The Map maps keyIds to category titles like '通知公告', '首页', '招生简章', etc.","commonSituations":"User passes a keyId from the URL of a different page that isn't in the curated list. The university reorganized its pages and old keyIds were removed. User guesses a numeric value not in the supported set.","solutions":["Use only the documented keyId values: 2 (通知公告), 1 (首页), 8 (招生简章), 12 (学校政策), 16 (硕士招生), 17 (博士招生), 23 (院所发文), 25 (数据统计).","Omit the keyId parameter entirely to default to '2' (通知公告).","If the university added a new category, add it to the `yjszs` Map at the top of `lib/routes/nudt/yjszs.ts`."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Validate keyId against the yjszs Map before use\nconst validKeyIds = new Set(yjszs.keys());\nif (!validKeyIds.has(keyId)) {\n    throw new InvalidParameterError(\n        `Invalid keyId '${keyId}'. Valid values: ${[...validKeyIds].join(', ')}`\n    );\n}","typeGuard":"function isValidKeyId(keyId: string, map: Map<string, unknown>): keyId is string {\n    return map.has(keyId);\n}","tryCatchPattern":null,"preventionTips":["Use only documented keyId values from the route description table.","Omit keyId to use the default ('2').","Keep the yjszs Map and route description in sync when adding/removing categories."],"tags":["validation","nudt","invalid-parameter","chinese-site","university"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}