DIYgod/RSSHub · error · InvalidParameterError

Unknown region: ${region}

Error message

Unknown region: ${region}

What it means

InvalidParameterError thrown by the Yahoo news provider-helper (新聞來源列表) handler when ctx.req.param('region') is not 'hk' or 'tw'. The provider-list endpoint is only meaningful for HK/TW Yahoo, whose archive is organized by news provider keys.

Source

Thrown at lib/routes/yahoo/news/provider-helper.ts:35

        supportScihub: false,
    },
    radar: [
        {
            source: ['hk.news.yahoo.com/'],
        },
        {
            source: ['tw.news.yahoo.com/'],
        },
    ],
    name: '新聞來源列表',
    maintainers: ['TonyRL', 'williamgateszhao'],
    handler,
};

async function handler(ctx) {
    const region = ctx.req.param('region');
    if (!['hk', 'tw'].includes(region)) {
        throw new InvalidParameterError(`Unknown region: ${region}`);
    }

    const providerList = await getProviderList(region);

    const items = providerList.map((provider) => ({
        ...provider,
        description: provider.key,
    }));

    return {
        title: 'Yahoo 新聞 - 新聞來源列表',
        link: `https://${region}.news.yahoo.com`,
        image: 'https://s.yimg.com/cv/apiv2/social/images/yahoo_default_logo-1200x1200.png',
        item: items,
    };
}

View on GitHub (pinned to bed535e087)

Solutions

  1. Use 'hk' or 'tw' as the region segment.
  2. For other regions there is no provider list — use the region's native RSS categories via /yahoo/news/:region/:category.
Defensive patterns

Strategy: validation

Validate before calling

function requireHkTwRegion(region: string) {
    if (!['hk', 'tw'].includes(region)) {
        throw new InvalidParameterError(`Unknown region: ${region}. The provider list supports only hk and tw.`);
    }
}

Type guard

function isHkTwRegion(value: string): value is 'hk' | 'tw' {
    return value === 'hk' || value === 'tw';
}

Prevention

When it happens

Trigger: A request to the provider-helper route with region other than hk/tw. The guard fires before getProviderList(region) is invoked.

Common situations: Caller pointed a non-HK/TW region at this helper route expecting a provider list; integrator reused a region token from the general news route.

Related errors


AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12). Data as JSON: /api/errors/733f414626cbcb3b. Report an issue: GitHub.