{"record":{"id":"fe60de572c04fbce","repo":"DIYgod/RSSHub","slug":"invalid-group-group-valid-values-all-noti","errorCode":null,"errorMessage":"Invalid group: \"${group}\". Valid values: ALL, notices, events, news","messagePattern":"Invalid group: \"(.+?)\"\\. Valid values: ALL, notices, events, news","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"lib/routes/hypergryph/endfield/news.ts","lineNumber":55,"sourceCode":"            source: ['endfield.hypergryph.com/news'],\n        },\n    ],\n    name: '明日方舟：终末地 - 游戏公告与新闻',\n    maintainers: ['E-larex'],\n    handler,\n    url: 'endfield.hypergryph.com/news',\n    description: `| 全部 | 公告    | 活动   | 新闻 |\n| ---- | ------- | ------ | ---- |\n| ALL  | notices | events | news |`,\n};\n\nasync function handler(ctx) {\n    const { group = 'ALL' } = ctx.req.param();\n\n    const normalizedGroup = group.toLowerCase();\n    const validTabs = new Set(['notices', 'events', 'news']);\n    if (normalizedGroup !== 'all' && !validTabs.has(normalizedGroup)) {\n        throw new Error(`Invalid group: \"${group}\". Valid values: ALL, notices, events, news`);\n    }\n\n    const apiUrl = 'https://web-news.hypergryph.com/api/bulletin?lang=zh-cn&code=endfield_web&page=1&pageSize=10' + (normalizedGroup === 'all' ? '' : `&tabs[]=${normalizedGroup}`);\n\n    const bulletinList: NewsItem[] = await cache.tryGet(\n        `hypergryph:endfield:news:${normalizedGroup}`,\n        async () => {\n            const response = await ofetch(apiUrl);\n            return response.data.list as NewsItem[];\n        },\n        config.cache.routeExpire,\n        false\n    );\n\n    const list = parseList(bulletinList);\n\n    const items = await Promise.all(\n        list.map((item) =>","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/hypergryph/endfield/news.ts#L37-L73","documentation":"Thrown by the Hypergryph Endfield (明日方舟：终末地) news route when the `:group` path parameter is not `ALL`, `notices`, `events`, or `news`. The handler normalizes the value to lowercase and checks against a `Set` of valid tab names, plus the special case `all`. The error message includes the invalid value and lists valid options. The default is `ALL` when the parameter is omitted, so omitting it is safe.","triggerScenarios":"Requesting `/hypergryph/endfield/news/<group>` where `<group>` is not one of the four valid values. The validation is case-insensitive (lowercased first), so `NOTICES` would pass but `notice` (missing the 's') would fail.","commonSituations":"Typo in the group name (e.g. `notice` instead of `notices`, `event` instead of `events`, `new` instead of `news`), or using a singular form.","solutions":["Use `ALL`, `notices`, `events`, or `news` — or omit the parameter (defaults to `ALL`).","As a maintainer: switch to `InvalidParameterError` for HTTP 400 semantics."],"exampleFix":"// before (broken)\n// GET /hypergryph/endfield/news/notice\n\n// after (correct)\n// GET /hypergryph/endfield/news/notices","handlingStrategy":"validation","validationCode":"const VALID_GROUPS = ['all', 'notices', 'events', 'news'];\nfunction isValidGroup(group: string): boolean {\n    return VALID_GROUPS.includes(group.toLowerCase());\n}","typeGuard":"function isValidEndfieldGroup(group: string): group is 'ALL' | 'notices' | 'events' | 'news' | 'all' {\n    const normalized = group.toLowerCase();\n    return normalized === 'all' || new Set(['notices', 'events', 'news']).has(normalized);\n}","tryCatchPattern":null,"preventionTips":["Use `InvalidParameterError` for HTTP 400 consistency.","Note the plural forms: `notices`, `events`, `news` (not singular).","Omit the group parameter to default to `ALL`."],"tags":["parameter-validation","rsshub","game"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}