{"record":{"id":"5aacbd8b0d175ae2","repo":"DIYgod/RSSHub","slug":"invalid-type-requestedtype-valid-types-are","errorCode":null,"errorMessage":"Invalid type: ${requestedType}. Valid types are: ${validTypes}","messagePattern":"Invalid type: (.+?)\\. Valid types are: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/routes/zju/sis/index.ts","lineNumber":143,"sourceCode":"| 0        | 1        | 2        | 3        | 4        | 5        | 6        | 7        | 8        | 9        | 10         | 11       | 12       | 13       |`,\n    maintainers: ['Alex222222222222'],\n    handler: handleSisRequest,\n    url: 'www.sis.zju.edu.cn',\n};\n\n/**\n * Main handler function for processing SIS (School of International Studies) news requests\n * @param ctx - The request context containing route parameters\n * @returns Promise with RSS feed data including title, link, and news items\n */\nasync function handleSisRequest(ctx) {\n    const requestedType = Number.parseInt(ctx.req.param('type'));\n    const categoryInfo = categoryMap.get(requestedType);\n\n    // Validate the requested category type\n    if (!categoryInfo) {\n        const validTypes = categoryMap.keys().toArray().join(', ');\n        throw new Error(`Invalid type: ${requestedType}. Valid types are: ${validTypes}`);\n    }\n\n    const categoryUrl = `${base}${categoryInfo.id}`;\n\n    // Fetch news items from all relevant categories\n    const allNewsItems = await fetchNewsItemsByCategory(categoryInfo.id);\n\n    // Enrich each news item with detailed content\n    const enrichedItems = await Promise.all(allNewsItems.map((item) => enrichNewsItemWithDetails(item, categoryUrl)));\n\n    return {\n        title: categoryInfo.title,\n        link: categoryUrl,\n        item: enrichedItems,\n    };\n}\n","sourceCodeStart":125,"sourceCodeEnd":160,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/zju/sis/index.ts#L125-L160","documentation":"The SIS (School of International Studies) counterpart of error 678. The handler parses the `:type` path parameter as an integer, looks it up in `categoryMap`, and on a miss throws with the requested type plus the full list of valid types. Identical pattern, different category set.","triggerScenarios":"The caller requests a `type` not present in the SIS route's `categoryMap` — an out-of-range integer, a non-numeric string that `Number.parseInt` turns into `NaN`, or a category code the SIS route doesn't model.","commonSituations":"User supplies a type number outside the documented range; passes a category name/label instead of its numeric code; copies a type valid for the math route but not for SIS. `NaN` from non-numeric input is the usual culprit.","solutions":["Use one of the valid type numbers listed in the error message (consult the SIS route's category table).","Confirm the number against the SIS-specific table — it is not interchangeable with the math route's types.","Validate that the input is numeric before it reaches the route to avoid `NaN` coercion."],"exampleFix":"// before — wrong / non-numeric type for SIS\n// GET /zju/sis/99   -> Invalid type: 99. Valid types are: ...\n// GET /zju/sis/news -> Invalid type: NaN ...\n// after — valid SIS type\n// GET /zju/sis/0","handlingStrategy":"validation","validationCode":"function validateSisType(raw, categoryMap) {\n    const type = Number.parseInt(raw, 10);\n    if (!Number.isFinite(type) || !categoryMap.has(type)) {\n        throw new Error(`Invalid type: ${raw}. Valid: ${[...categoryMap.keys()].join(', ')}`);\n    }\n    return type;\n}","typeGuard":"function isValidSisType(raw: string, categoryMap: Map<number, unknown>): raw is `${number}` {\n    const n = Number.parseInt(raw, 10);\n    return Number.isFinite(n) && categoryMap.has(n);\n}","tryCatchPattern":null,"preventionTips":["Validate the type is a finite integer present in the SIS categoryMap before lookup.","Guard against non-numeric input to avoid silent NaN coercion.","Remember SIS types are a different set from math types — validate against the right map."],"tags":["zju","sis","validation","route-parameter","allow-list"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}