DIYgod/RSSHub · warning · InvalidParameterError

Invalid domain

Error message

Invalid domain

What it means

InvalidParameterError thrown when the `domain` path param of /bt0/mv/:domain/:number does not match /^[1-9]$/ (a single digit 1-9). The domain selects which mirror (https://www.{domain}bt0.com) to query; the regex prevents SSRF and malformed host construction.

Source

Thrown at lib/routes/bt0/mv.ts:33

        supportBT: true,
        supportPodcast: false,
        supportScihub: false,
    },
    radar: [
        {
            source: ['2bt0.com/mv/'],
        },
    ],
    name: '影视资源下载列表',
    maintainers: ['miemieYaho'],
    handler,
};

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

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

    const data = (await doGot(0, host, _link)).data;
    const items = Object.values<any[]>(data.ecca).flatMap((item) =>
        item.map((i) => ({
            title: i.zname,
            guid: i.zname,
            description: `${i.zname}[${i.zsize}]`,
            link: `${host}/tr/${i.id}.html`,
            pubDate: i.ezt,
            enclosure_type: 'application/x-bittorrent',

View on GitHub (pinned to bed535e087)

Solutions

  1. Use a single digit 1-9 for the domain param, e.g. /bt0/mv/2/123456.
  2. Omit domain to use the default '2'.
  3. Ensure the route URL is not being constructed with extra characters.

Example fix

// before
if (!/^[1-9]$/.test(domain)) {
    throw new InvalidParameterError('Invalid domain');
}
// after (state the allowed format)
if (!/^[1-9]$/.test(domain)) {
    throw new InvalidParameterError(`Invalid domain '${domain}': expected a single digit 1-9`);
}
Defensive patterns

Strategy: validation

Validate before calling

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

Type guard

const isBt0Domain = (d: string): boolean => /^[1-9]$/.test(d);

Prevention

When it happens

Trigger: A request to /bt0/mv/:domain/:number where domain is not exactly one character in '1'..'9' — e.g. '2 ', '0', '12', a letter, or omitted (default '2' is valid so this only fires on an explicit bad value).

Common situations: Passing a two-digit mirror id; passing the full hostname instead of the single digit; URL encoding artifacts.

Related errors


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