{"record":{"id":"1b7f563e2783941e","repo":"DIYgod/RSSHub","slug":"unknown-region-region","errorCode":null,"errorMessage":"Unknown region: ${region}","messagePattern":"Unknown region: (.+?)","errorType":"validation","errorClass":"InvalidParameterError","httpStatus":503,"severity":"error","filePath":"lib/routes/yahoo/news/index.ts","lineNumber":112,"sourceCode":"| All    | US | Politics | World | Science | Tech |\n| ------ | -- | -------- | ----- | ------- | ---- |\n| (留空) | us | politics | world | science | tech |\n\n再举例，由于 uk.news.yahoo.com/rss/ukoriginal 可以访问并且有较新的新闻，所以 /yahoo/news/uk/ukoriginal 是一个有效的 RSSHub 路由。\n\n\\`作者 author\\`\n\n对于香港和台湾雅虎，请使用另一个 \"新聞來源\" 路由。\n\n对于其他雅虎新闻，本路由的 RSS 中提供了 author 字段，可使用 RSSHub 的内置 \"内容过滤\" 功能，例如 /yahoo-wg/news/tw/technology?filter\\\\_author=Yahoo%20Tech|Engadget 可从台湾雅虎的科技新闻中过滤出作者名称中包含 Yahoo Tech 或者 Engadget 的新闻，即瘾科技中文版。`,\n    },\n};\n\nasync function handler(ctx) {\n    const region = ['en', 'EN', 'us', 'US', 'www', 'WWW', ''].includes(ctx.req.param('region')) ? '' : ctx.req.param('region').toLowerCase();\n    const category = ctx.req.param('category');\n    if (!['hk', 'tw', 'au', 'ca', 'fr', 'malaysia', 'nz', 'sg', 'uk', ''].includes(region)) {\n        throw new InvalidParameterError(`Unknown region: ${region}`);\n    }\n\n    const limit = ctx.req.query('limit') ? Number(ctx.req.query('limit')) : 20;\n\n    if (['hk', 'tw'].includes(region)) {\n        const { categoryMap } = regionConfig[region];\n        if (category && !Object.hasOwn(categoryMap, category)) {\n            throw new InvalidParameterError(`Unknown category for ${region}: ${category}`);\n        }\n        const tags = category ? categoryMap[category].tags : undefined;\n\n        const response = await getArchive(region, limit, tags);\n        const list = parseList(region, response);\n\n        const items = await Promise.all(list.map((item) => parseItem(item)));\n\n        return {\n            title: `Yahoo 新聞 ${region.toUpperCase()} - ${category ? categoryMap[category].name : '所有類別'}`,","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/yahoo/news/index.ts#L94-L130","documentation":"InvalidParameterError thrown by the Yahoo news handler when the :region segment is not in the allow-list ['hk','tw','au','ca','fr','malaysia','nz','sg','uk',''] (after normalizing en/EN/us/US/www/WWW to the empty US-default string). It guards against unsupported Yahoo regional domains before building any URL.","triggerScenarios":"A request to /yahoo/news/:region/:category where region.lowercase() is outside the allow-list — e.g. /yahoo/news/de/..., /yahoo/news/in/..., or /yahoo/news/japan/.... The normalization step maps several US aliases to '', so those pass; anything else hits the guard.","commonSituations":"Caller assumed a Yahoo region (e.g. Germany, India, Japan) is supported when only the listed regions are; typo; integrator passed a full hostname instead of a region token.","solutions":["Use one of the supported regions: hk, tw, au, ca, fr, malaysia, nz, sg, uk, or en/us/www for the US default.","If you need an unsupported region, check whether *.news.yahoo.com/rss/<category> works and request it be added, or use Yahoo's native RSS directly.","Verify spelling — 'malaysia' is the full word, not 'my'."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const US_ALIASES = new Set(['en', 'us', 'www', '']);\nconst SUPPORTED_REGIONS = new Set(['hk', 'tw', 'au', 'ca', 'fr', 'malaysia', 'nz', 'sg', 'uk', '']);\nfunction normalizeYahooRegion(raw: string | undefined) {\n    const lower = (raw ?? '').toLowerCase();\n    const region = US_ALIASES.has(lower) ? '' : lower;\n    if (!SUPPORTED_REGIONS.has(region)) {\n        throw new InvalidParameterError(`Unknown region: ${region}. Supported: ${[...SUPPORTED_REGIONS].filter(Boolean).join(', ')} (or en/us/www for US).`);\n    }\n    return region;\n}","typeGuard":"const SUPPORTED_REGIONS = new Set(['hk', 'tw', 'au', 'ca', 'fr', 'malaysia', 'nz', 'sg', 'uk', '']);\nfunction isYahooRegion(value: string): boolean {\n    return SUPPORTED_REGIONS.has(value);\n}","tryCatchPattern":null,"preventionTips":["Normalize to lowercase and map US aliases before validating.","Keep the allow-list in one constant shared by all Yahoo news routes.","Remember 'malaysia' is the full word, not the ISO code 'my'."],"tags":["yahoo","validation","route-param","region"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}