DIYgod/RSSHub · warning · InvalidParameterError

pattern not matched

Error message

pattern not matched

What it means

Thrown by the Suzhou government news route when the `:uid` path parameter does not match any `case` in the handler's `switch` statement (lines 65–125). Each case corresponds to a known channel slug such as `news`, `qxkx`, `bmdt`, `rdzt`, `zwgg`, etc. The `default` branch throws `InvalidParameterError` (HTTP 400) with the message 'pattern not matched'.

Source

Thrown at lib/routes/gov/suzhou/news.ts:124

            title = '苏州市政府 - 区县专题';
            break;
        case 'zwgg':
            apiUrl = `${rootUrl}/szinf/info/getInfoCommon/?pagesize=15&currpage=1&channelid=260915178a1f4c4fac44c4bf6378c9b0`;
            url = `${rootUrl}/szsrmzf/zwgg/nav_list.shtml`;
            title = '苏州市政府 - 政务公告';
            break;
        case 'mszx':
            apiUrl = `${rootUrl}/szinf/info/getInfoCommon/?pagesize=15&currpage=1&channelid=dc60acecb0be46b89d42272dcb8bd32b`;
            url = `${rootUrl}/szsrmzf/mszx/nav_list.shtml`;
            title = '苏州市政府 - 便民公告';
            break;
        case 'bmzx':
            apiUrl = `${rootUrl}/szinf/info/getInfoCommon/?pagesize=15&currpage=1&channelid=b015bfa5e5514cc9a26cd9f956ef8e69`;
            url = `${rootUrl}/szsrmzf/bmzx/bmzx_list.shtml`;
            title = '苏州市政府 - 民生资讯';
            break;
        default:
            throw new InvalidParameterError('pattern not matched');
    }
    if (apiUrl) {
        const response = await got(apiUrl);
        const infoList = response.data.infolist.map((item) => ({
            title: item.title,
            link: item.link.startsWith('http') ? item.link : new URL(item.link, rootUrl).href,
            pubDate: timezone(parseDate(item.pubtime, 'YYYY-MM-DD HH:mm:ss'), 8),
        }));

        items = await Promise.all(
            infoList.map((item) =>
                // 获取全文
                cache.tryGet(item.link, async () => {
                    const response = await got(item.link);
                    const $ = load(response.data);
                    item.description = $('ucapcontent').html();

                    return item;

View on GitHub (pinned to bed535e087)

Solutions

  1. Consult the route description table for the full list of valid `:uid` values: `news`/`szyw`, `qxkx`/`district`, `bmdt`, `xwsp`, `rdzt`, `sbjzt`, `zxrdzt`, `wqzt`, `qxzt`, `zwgg`, `mszx`, `bmzx`.
  2. Use one of those exact slugs in the URL path.

Example fix

// before (broken)
// GET /gov/suzhou/news/sports

// after (correct)
// GET /gov/suzhou/news/bmdt
Defensive patterns

Strategy: validation

Validate before calling

const VALID_UIDS = ['news', 'szyw', 'qxkx', 'district', 'bmdt', 'xwsp', 'rdzt', 'sbjzt', 'zxrdzt', 'wqzt', 'qxzt', 'zwgg', 'mszx', 'bmzx'] as const;
function isValidUid(uid: string): boolean {
    return (VALID_UIDS as readonly string[]).includes(uid);
}

Type guard

function isKnownSuzhouChannel(uid: string): uid is typeof VALID_UIDS[number] {
    return (VALID_UIDS as readonly string[]).includes(uid);
}

Prevention

When it happens

Trigger: Requesting `/gov/suzhou/news/<uid>` where `<uid>` does not match any `case` label in the handler's `switch` statement. Each case corresponds to a known channel slug; any other value falls through to the `default` branch.

Common situations: User enters a channel slug not in the switch (e.g. `sports`, `finance`), uses an old slug that was removed, or mistypes a valid one like `qxkx` as `qxk`. The route description lists all valid slugs in two markdown tables.

Related errors


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