{"record":{"id":"b4541bf3fe9df007","repo":"DIYgod/RSSHub","slug":"invalid-type-b4541b","errorCode":null,"errorMessage":"invalid type","messagePattern":"invalid type","errorType":"validation","errorClass":"InvalidParameterError","httpStatus":503,"severity":"warning","filePath":"lib/routes/njust/cs.ts","lineNumber":43,"sourceCode":"        requirePuppeteer: true,\n        antiCrawler: false,\n        supportBT: false,\n        supportPodcast: false,\n        supportScihub: false,\n    },\n    name: '计算机学院',\n    maintainers: ['Horacecxk', 'jasongzy'],\n    handler,\n    description: `| 学院新闻 | 通知公告 | 学术动态 |\n| -------- | -------- | -------- |\n| xyxw     | tzgg     | xsdt     |`,\n};\n\nasync function handler(ctx) {\n    const type = ctx.req.param('type') ?? 'xyxw';\n    const info = map.get(type);\n    if (!info) {\n        throw new InvalidParameterError('invalid type');\n    }\n    const id = info.id;\n    const siteUrl = host + id + '/list.htm';\n    const html = await getContent(siteUrl, true);\n    const $ = load(html);\n    const list = $('div#wp_news_w9').find('a');\n\n    return {\n        title: info.title,\n        link: siteUrl,\n        item: list.toArray().map((item) => ({\n            title: $(item).find('span[class=\"column-news-title\"]').text().trim(),\n            pubDate: timezone(parseDate($(item).find('span[class=\"column-news-date news-date-hide\"]').text(), 'YYYY-MM-DD'), 8),\n            link: $(item).attr('href'),\n        })),\n    };\n}\n","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/njust/cs.ts#L25-L61","documentation":"InvalidParameterError from the NJUST Computer Science route. The handler reads ctx.req.param('type') (default 'xyxw'), looks it up in a Map, and throws if undefined. This is the idiomatic RSSHub pattern for type validation and correctly returns a 400-class error.","triggerScenarios":"Calling /njust/cs/:type with a value not present in the route's map — e.g. typo, or a category that exists on another NJUST sub-site but not CS. Valid keys for this route are xyxw / tzgg / xsdt (per the description table).","commonSituations":"User mistypes the code; user copies a type from a sibling NJUST route (cwc, dgxg, eoe, jwc) that uses different keys.","solutions":["Use one of the documented codes for this route: xyxw (学院新闻), tzgg (通知公告), xsdt (学术动态).","Do not assume codes are shared across NJUST sub-sites — each route has its own map.","Check the route's description table for the authoritative list."],"exampleFix":"// before\nconst info = map.get(type);\nif (!info) {\n    throw new InvalidParameterError('invalid type');\n}\n\n// after — caller fix\n//   GET /njust/cs/xyxw   ✓\n//   GET /njust/cs/tzgg   ✓","handlingStrategy":"validation","validationCode":"const VALID = new Set(['xyxw','tzgg','xsdt']);\nfunction buildNjustCsUrl(type) {\n  if (!VALID.has(type)) throw new Error(`invalid type '${type}'. Valid: ${[...VALID].join(', ')}`);\n  return host + MAP[type] + '/list.htm';\n}","typeGuard":"const isCsType = (t: string): t is 'xyxw'|'tzgg'|'xsdt' => VALID.has(t);","tryCatchPattern":null,"preventionTips":["Do not assume codes are shared across NJUST sub-sites — each route has its own map.","Validate client-side using that route's description table.","Surface the valid set in your client error."],"tags":["validation","route-parameter","user-input","njust"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}