{"record":{"id":"2db64a9412bd6fbd","repo":"DIYgod/RSSHub","slug":"invalid-region-2db64a","errorCode":null,"errorMessage":"Invalid region","messagePattern":"Invalid region","errorType":"validation","errorClass":"InvalidParameterError","httpStatus":null,"severity":"error","filePath":"lib/routes/eprice/rss.tsx","lineNumber":39,"sourceCode":"        antiCrawler: false,\n        supportBT: false,\n        supportPodcast: false,\n        supportScihub: false,\n    },\n    name: '最新消息',\n    maintainers: ['TonyRL'],\n    handler,\n    description: `地区：\n\n| hk   | tw   |\n| ---- | ---- |\n| 香港 | 台湾 |`,\n};\n\nasync function handler(ctx) {\n    const region = ctx.req.param('region') ?? 'tw';\n    if (!allowRegion.has(region)) {\n        throw new InvalidParameterError('Invalid region');\n    }\n\n    const feed = await parser.parseURL(`https://www.eprice.com.${region}/news/rss.xml`);\n\n    for (const e of feed.items) {\n        e.link = e.link!.replace(/^http:\\/\\//i, 'https://');\n    }\n\n    const items = await Promise.all(\n        feed.items.map((item) =>\n            cache.tryGet(item.link!, async () => {\n                const response = await got(item.link);\n\n                const $ = load(response.data);\n\n                // remove unwanted elements\n                $('noscript').remove();\n                $('div[id^=dablewidget]').remove();","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/eprice/rss.tsx#L21-L57","documentation":"The eprice RSS route targets regional eprice domains and restricts the `region` path parameter to an allowRegion Set containing only `tw` and `hk`. Any other value (or a value that bypasses the default) throws InvalidParameterError before the RSS fetch.","triggerScenarios":"`/eprice/<region>` where <region> is not exactly `tw` or `hk` — e.g. `/eprice/sg`, `/eprice/cn`, `/eprice/HK` (case-sensitive).","commonSituations":"Guessing a region code; supplying an uppercase variant; passing a country code for a region eprice does not serve.","solutions":["Use `tw` (default) or `hk`.","Omit the region segment to fall back to `tw`."],"exampleFix":"// before\n//   /eprice/sg\n// after\n//   /eprice/tw","handlingStrategy":"validation","validationCode":"const allowRegion = new Set(['tw', 'hk']);\nfunction isValidRegion(region: string): boolean {\n  return allowRegion.has(region);\n}","typeGuard":"function isValidRegion(region: string): region is 'tw' | 'hk' {\n  return region === 'tw' || region === 'hk';\n}","tryCatchPattern":null,"preventionTips":["Normalise the region to lowercase before checking.","Document the two supported regions in the route description table."],"tags":["validation","enum"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}