DIYgod/RSSHub · warning · Error

Unknown bank: ${bank}

Error message

Unknown bank: ${bank}

What it means

Thrown by the Flyert credit card route's switch statement when the `bank` path parameter does not match any of the 18 known case values (creditcard, pufa, zhaoshang, zhongxin, jiaotong, zhonghang, gongshang, guangfa, nongye, jianshe, huifeng, mingsheng, xingye, huaqi, shanghai, wuka, 137, 145, intcreditcard). The error is a plain `Error` (not `InvalidParameterError`), which means it surfaces as a generic 500-level error rather than a 400-level parameter error. The switch also constructs the target URL `${host}/forum-${bank}-1.html` before the switch, so an invalid bank already produced a URL that would fail.

Source

Thrown at lib/routes/flyert/creditcard.ts:122

            bankname = '花旗银行';
            break;
        case 'shanghai':
            bankname = '上海银行';
            break;
        case 'wuka':
            bankname = '无卡支付';
            break;
        case '137':
            bankname = '投资理财';
            break;
        case '145':
            bankname = '网站权益汇';
            break;
        case 'intcreditcard':
            bankname = '境外信用卡';
            break;
        default:
            throw new Error(`Unknown bank: ${bank}`);
    }

    const response = await got.get(target, {
        responseType: 'buffer',
    });

    const $ = load(gbk2utf8(response.data));

    const list = $("[id*='normalthread']").toArray();

    const result = await util.ProcessFeed(list, cache);

    return {
        title: `飞客茶馆信用卡 - ${bankname}`,
        link: 'https://www.flyert.com.cn/',
        description: `飞客茶馆信用卡 - ${bankname}`,
        item: result,
    };

View on GitHub (pinned to bed535e087)

Solutions

  1. Use one of the documented bank identifiers: `creditcard`, `pufa`, `zhaoshang`, `zhongxin`, `jiaotong`, `zhonghang`, `gongshang`, `guangfa`, `nongye`, `jianshe`, `huifeng`, `mingsheng`, `xingye`, `huaqi`, `shanghai`, `wuka`, `137`, `145`, or `intcreditcard`.
  2. Check the route description table in creditcard.ts for the complete mapping.
  3. If the bank exists on flyert.com.cn but is not listed, request it be added or contribute a PR with a new case.

Example fix

// before
default:
    throw new Error(`Unknown bank: ${bank}`);

// after — use InvalidParameterError for proper 400-level response
default:
    throw new InvalidParameterError(`Unknown bank: ${bank}. Valid banks: creditcard, pufa, zhaoshang, zhongxin, jiaotong, zhonghang, gongshang, guangfa, nongye, jianshe, huifeng, mingsheng, xingye, huaqi, shanghai, wuka, 137, 145, intcreditcard`);
Defensive patterns

Strategy: validation

Validate before calling

const VALID_BANKS = new Set([
    'creditcard', 'pufa', 'zhaoshang', 'zhongxin', 'jiaotong', 'zhonghang',
    'gongshang', 'guangfa', 'nongye', 'jianshe', 'huifeng', 'mingsheng',
    'xingye', 'huaqi', 'shanghai', 'wuka', '137', '145', 'intcreditcard'
]);

function validateBank(bank: string | undefined): string {
    if (!bank || !VALID_BANKS.has(bank)) {
        throw new InvalidParameterError(`Unknown bank: ${bank}. Valid: ${[...VALID_BANKS].join(', ')}`);
    }
    return bank;
}

Type guard

const BANK_IDS = ['creditcard','pufa','zhaoshang','zhongxin','jiaotong','zhonghang','gongshang','guangfa','nongye','jianshe','huifeng','mingsheng','xingye','huaqi','shanghai','wuka','137','145','intcreditcard'] as const;
type BankId = typeof BANK_IDS[number];

function isBankId(value: string): value is BankId {
    return (BANK_IDS as readonly string[]).includes(value);
}

Prevention

When it happens

Trigger: A user passes a bank identifier not in the switch — e.g., `/flyert/creditcard/citic` (English name instead of pinyin), `/flyert/creditcard/ICBC`, or a typo like `/flyert/creditcard/zhongx`. The default case fires with the raw bank value.

Common situations: User guesses a bank name in English or abbreviated form instead of the expected pinyin slug. User uses uppercase instead of lowercase. The route documentation table is not consulted. A new bank section is added to the Flyert forum but not to this route.

Related errors


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