{"record":{"id":"08c6d49799bc0946","repo":"DIYgod/RSSHub","slug":"invalid-type-type-08c6d4","errorCode":null,"errorMessage":"Invalid type: ${type}","messagePattern":"Invalid type: (.+?)","errorType":"validation","errorClass":"InvalidParameterError","httpStatus":null,"severity":"error","filePath":"lib/routes/gamebase/news.tsx","lineNumber":41,"sourceCode":"            {images?.length\n                ? images.map((image) =>\n                      image?.src ? (\n                          <figure key={image.src}>\n                              <img src={image.src} alt={image.alt} />\n                          </figure>\n                      ) : null\n                  )\n                : null}\n            {intro ? <blockquote>{intro}</blockquote> : null}\n            {description ? <>{raw(description)}</> : null}\n        </>\n    );\n\nexport const handler = async (ctx: Context): Promise<Data> => {\n    const { type = 'newslist', category = 'all' } = ctx.req.param();\n\n    if (!types.hasOwnProperty(type)) {\n        throw new InvalidParameterError(`Invalid type: ${type}`);\n    }\n\n    const limit = Number(ctx.req.query('limit') ?? '30');\n\n    const baseUrl = 'https://news.gamebase.com.tw';\n    const targetUrl: string = new URL(`news${category === 'all' ? '' : `/newslist?type=${category}`}`, baseUrl).href;\n    const apiBaseUrl = 'https://api.gamebase.com.tw';\n    const apiUrl: string = new URL('api/news/getNewsList', apiBaseUrl).href;\n\n    const response = await ofetch(apiUrl, {\n        method: 'post',\n        body: {\n            GB_type: types[type],\n            category,\n            page: 1,\n        },\n    });\n","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/gamebase/news.tsx#L23-L59","documentation":"The Gamebase route supports a `type` path parameter validated against a `types` map containing only `newslist` and `r18list`. An `hasOwnProperty` check throws InvalidParameterError for any other value before the API call is made.","triggerScenarios":"`/gamebase/news/<type>` where <type> is not `newslist` or `r18list` — e.g. `/gamebase/news/latest`, `/gamebase/news/top`.","commonSituations":"Guessing a type value; typos; omitting the segment is safe (defaults to newslist).","solutions":["Use `newslist` (default) or `r18list`.","Omit the type segment to fall back to `newslist`."],"exampleFix":"// before\n//   /gamebase/news/latest\n// after\n//   /gamebase/news/newslist","handlingStrategy":"validation","validationCode":"const types = { newslist: 'newsList', r18list: 'newsPornList' } as const;\nfunction isValidType(type: string): type is keyof typeof types {\n  return Object.prototype.hasOwnProperty.call(types, type);\n}","typeGuard":"function isValidType(type: string): type is keyof typeof types {\n  return Object.prototype.hasOwnProperty.call(types, type);\n}","tryCatchPattern":null,"preventionTips":["Use a `const` object + keyof narrowing so the compiler tracks valid values.","Document the two types in the route description."],"tags":["validation","enum"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}