DIYgod/RSSHub · error · InvalidParameterError

Invalid region

Error message

Invalid region

What it means

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.

Source

Thrown at lib/routes/eprice/rss.tsx:39

        antiCrawler: false,
        supportBT: false,
        supportPodcast: false,
        supportScihub: false,
    },
    name: '最新消息',
    maintainers: ['TonyRL'],
    handler,
    description: `地区:

| hk   | tw   |
| ---- | ---- |
| 香港 | 台湾 |`,
};

async function handler(ctx) {
    const region = ctx.req.param('region') ?? 'tw';
    if (!allowRegion.has(region)) {
        throw new InvalidParameterError('Invalid region');
    }

    const feed = await parser.parseURL(`https://www.eprice.com.${region}/news/rss.xml`);

    for (const e of feed.items) {
        e.link = e.link!.replace(/^http:\/\//i, 'https://');
    }

    const items = await Promise.all(
        feed.items.map((item) =>
            cache.tryGet(item.link!, async () => {
                const response = await got(item.link);

                const $ = load(response.data);

                // remove unwanted elements
                $('noscript').remove();
                $('div[id^=dablewidget]').remove();

View on GitHub (pinned to bed535e087)

Solutions

  1. Use `tw` (default) or `hk`.
  2. Omit the region segment to fall back to `tw`.

Example fix

// before
//   /eprice/sg
// after
//   /eprice/tw
Defensive patterns

Strategy: validation

Validate before calling

const allowRegion = new Set(['tw', 'hk']);
function isValidRegion(region: string): boolean {
  return allowRegion.has(region);
}

Type guard

function isValidRegion(region: string): region is 'tw' | 'hk' {
  return region === 'tw' || region === 'hk';
}

Prevention

When it happens

Trigger: `/eprice/<region>` where <region> is not exactly `tw` or `hk` — e.g. `/eprice/sg`, `/eprice/cn`, `/eprice/HK` (case-sensitive).

Common situations: Guessing a region code; supplying an uppercase variant; passing a country code for a region eprice does not serve.

Related errors


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