{"record":{"id":"f67e298e02122ad0","repo":"DIYgod/RSSHub","slug":"invalid-type-type","errorCode":null,"errorMessage":"Invalid type: ${type}","messagePattern":"Invalid type: (.+?)","errorType":"validation","errorClass":"InvalidParameterError","httpStatus":503,"severity":"warning","filePath":"lib/routes/ea/apex-news.ts","lineNumber":29,"sourceCode":"    html: true,\n    breaks: true,\n});\n\nconst langEnum = new Set(['zh-hant', 'en']);\nconst typeEnum = new Set(['latest', 'game-updates', 'news-article']);\n\nasync function handler(ctx) {\n    const { lang = 'en', type = 'latest' } = ctx.req.param();\n    const apiParams = new URLSearchParams({\n        limit: '13',\n        gameSlug: 'apex-legends',\n        offset: '0',\n    });\n    if (!langEnum.has(lang)) {\n        throw new InvalidParameterError(`Invalid language: ${lang}`);\n    }\n    if (!typeEnum.has(type)) {\n        throw new InvalidParameterError(`Invalid type: ${type}`);\n    }\n    if (type !== 'latest') {\n        apiParams.append('typeSlug', type);\n    }\n    if (lang !== 'en') {\n        apiParams.append('locale', lang);\n    }\n    const apiUrl = `https://drop-api.ea.com/news-articles/pagination?${apiParams}`;\n    const newsItems = await ofetch(apiUrl);\n\n    type NewsItem = DataItem & {\n        slug: string;\n    };\n    const allItems: NewsItem[] = [newsItems.featured, ...newsItems.items].filter(Boolean).map((item) => ({\n        title: item.title,\n        description: item.summary,\n        link: `https://www.ea.com${lang === 'en' ? '/' : '/' + lang + '/'}games/apex-legends/apex-legends/news/${item.slug}`,\n        pubDate: parseDate(item.publishingDate),","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/ea/apex-news.ts#L11-L47","documentation":"Thrown as an `InvalidParameterError` when the `type` path parameter is not in the allowed set `{'latest', 'game-updates', 'news-article'}`. This is pre-flight validation that fires before the EA drop-api call, producing an HTTP 400-level response.","triggerScenarios":"A user requests `/ea/apex-news/<lang>/<type>` where `<type>` is not one of the three valid values — for example `news`, `updates`, `patch-notes`, or an empty/misspelled string. The typeEnum Set check fails immediately.","commonSituations":"User guesses a category slug from the EA website that is not supported by this route. A third-party integration passes a free-text type value. The user confuses the EA website's navigation labels with the route's accepted values.","solutions":["Use one of the three supported values: `latest`, `game-updates`, or `news-article`.","Omit the type parameter entirely to default to `latest` (all categories).","Check the route definition's `parameters.type.options` for the authoritative list."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const SUPPORTED_TYPES = new Set(['latest', 'game-updates', 'news-article']);\nfunction validateType(type: string | undefined): string {\n    const resolved = type ?? 'latest';\n    if (!SUPPORTED_TYPES.has(resolved)) {\n        throw new InvalidParameterError(`Invalid type: ${type}. Supported: latest, game-updates, news-article`);\n    }\n    return resolved;\n}","typeGuard":"function isSupportedType(type: string): type is 'latest' | 'game-updates' | 'news-article' {\n    return type === 'latest' || type === 'game-updates' || type === 'news-article';\n}","tryCatchPattern":null,"preventionTips":["Always check the route's parameter options for the authoritative list of valid values.","Default to 'latest' (all categories) when the type parameter is omitted.","Use the enum Set check early in the handler, before building API params."],"tags":["parameter-validation","enum-check","invalid-parameter-error"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}