DIYgod/RSSHub · warning · InvalidParameterError

Invalid sc

Error message

Invalid sc

What it means

InvalidParameterError thrown when the `sc` path param of /bt0/tlist/:domain/:sc does not match /^[1-5]$/. The sc selects a resource-list category on the bt0 mirror, and only categories 1-5 are valid; the guard prevents injecting an out-of-range sc into the getTList query string.

Source

Thrown at lib/routes/bt0/tlist.ts:45

    },
    radar: [
        {
            source: ['2bt0.com/tlist/'],
        },
    ],
    name: '最新资源列表',
    maintainers: ['miemieYaho'],
    handler,
};

async function handler(ctx) {
    const domain = ctx.req.param('domain') ?? '2';
    const sc = ctx.req.param('sc');
    if (!/^[1-9]$/.test(domain)) {
        throw new InvalidParameterError('Invalid domain');
    }
    if (!/^[1-5]$/.test(sc)) {
        throw new InvalidParameterError('Invalid sc');
    }

    const host = `https://www.${domain}bt0.com`;
    const _link = `${host}/prod/core/system/getTList?sc=${sc}`;

    const data = await doGot(0, host, _link);
    const items = data.data.list.map((item) => ({
        title: item.zname,
        guid: item.zname,
        description: `《${item.title}》  导演: ${item.daoyan}<br>编剧: ${item.bianji}<br>演员: ${item.yanyuan}<br>简介: ${item.conta.trim()}`,
        link: host + item.aurl,
        pubDate: item.eztime.endsWith('前') ? parseRelativeDate(item.eztime) : item.eztime,
        enclosure_type: 'application/x-bittorrent',
        enclosure_url: item.zlink,
        enclosure_length: genSize(item.zsize),
        itunes_item_image: item.epic,
    }));
    return {

View on GitHub (pinned to bed535e087)

Solutions

  1. Use a single digit 1-5 for sc, e.g. /bt0/tlist/2/1.
  2. Confirm the desired category's numeric code from the bt0 site's tlist UI.

Example fix

// before
if (!/^[1-5]$/.test(sc)) {
    throw new InvalidParameterError('Invalid sc');
}
// after
if (!/^[1-5]$/.test(sc)) {
    throw new InvalidParameterError(`Invalid sc '${sc}': expected a single digit 1-5`);
}
Defensive patterns

Strategy: validation

Validate before calling

if (!/^[1-5]$/.test(sc)) {
    throw new InvalidParameterError(`Invalid sc '${sc}': expected a single digit 1-5`);
}

Type guard

const isBt0Sc = (s: string): boolean => /^[1-5]$/.test(s);

Prevention

When it happens

Trigger: A request where sc is not a single digit in '1'..'5' — e.g. '6', '0', '01', a letter, or undefined.

Common situations: Guessing a category number > 5; passing a category name instead of its numeric code; omitting sc.

Related errors


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