{"record":{"id":"63bc200fefdbe19c","repo":"DIYgod/RSSHub","slug":"invalid-type-type-63bc20","errorCode":null,"errorMessage":"Invalid type: ${type}","messagePattern":"Invalid type: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/routes/gamersky/review.ts","lineNumber":72,"sourceCode":"    },\n    radar: [\n        {\n            source: ['www.gamersky.com/review'],\n            target: '/review',\n        },\n    ],\n    name: '评测',\n    maintainers: ['yy4382'],\n    description: mdTableBuilder(idNameMap),\n    handler,\n};\n\nasync function handler(ctx: Context) {\n    const type = ctx.req.param('type') ?? 'pc';\n\n    const idName = idNameMap.find((item) => item.type === type);\n    if (!idName) {\n        throw new Error(`Invalid type: ${type}`);\n    }\n\n    const response = await getArticleList(idName.nodeId);\n    const list = parseArticleList(response);\n    const fullTextList = await Promise.all(list.map((item) => getArticle(item)));\n    return {\n        title: `${idName.name} - 游民星空评测`,\n        link: 'https://www.gamersky.com/review',\n        item: fullTextList,\n    };\n}\n","sourceCodeStart":54,"sourceCodeEnd":84,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/gamersky/review.ts#L54-L84","documentation":"The Gamersky review route mirrors the news route: a type path parameter (default 'pc') is searched in a static idNameMap, and a miss throws 'Invalid type: {type}'. It guards against fetching reviews for an unknown nodeId.","triggerScenarios":"Requesting /gamersky/review/{type} with a type absent from idNameMap — typo, archived review category, or a value belonging to the news/ent routes.","commonSituations":"Users conflating review types with news types; Gamersky retiring a review section; casing or whitespace differences in the supplied type.","solutions":["Check the route description table for the valid type codes for reviews specifically.","Update idNameMap if a review section was renamed.","Trim the input before lookup."],"exampleFix":"// before\nconst idName = idNameMap.find((item) => item.type === type);\nif (!idName) {\n    throw new Error(`Invalid type: ${type}`);\n}\n\n// after\nconst idName = idNameMap.find((item) => item.type === type.trim());\nif (!idName) {\n    const valid = idNameMap.map((i) => i.type).join(', ');\n    throw new InvalidParameterError(`Invalid type \"${type}\". Valid: ${valid}`);\n}","handlingStrategy":"validation","validationCode":"const validTypes = idNameMap.map((i) => i.type);\nif (!validTypes.includes(type.trim())) {\n  throw new InvalidParameterError(`Invalid type. Valid: ${validTypes.join(', ')}`);\n}","typeGuard":"const isValidType = (t: string): t is string => idNameMap.some((i) => i.type === t);","tryCatchPattern":null,"preventionTips":["List valid review types in the error message.\nTrim input.\nEnsure docs distinguish review vs news type sets."],"tags":["validation","user-input","enum"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}