DIYgod/RSSHub · error · InvalidParameterError

Invalid domain

Error message

Invalid domain

What it means

Identical guard to the Gamme category route: the tag route builds https://{domain}.gamme.com.tw/tag/{tag} and validates domain via isValidHost first. A failure throws InvalidParameterError('Invalid domain').

Source

Thrown at lib/routes/gamme/tag.ts:26

import { isValidHost } from '@/utils/valid-host';

export const route: Route = {
    path: '/:domain/tag/:tag',
    categories: ['new-media'],
    example: '/gamme/news/tag/歐派',
    parameters: {
        domain: '網站,`news` 為宅宅新聞,`sexynews` 為西斯新聞',
        tag: '標籤,可在 URL 找到',
    },
    name: '標籤',
    maintainers: ['TonyRL'],
    handler,
};

async function handler(ctx) {
    const { domain = 'news', tag } = ctx.req.param();
    if (!isValidHost(domain)) {
        throw new InvalidParameterError('Invalid domain');
    }
    const baseUrl = `https://${domain}.gamme.com.tw`;
    const pageUrl = `${baseUrl}/tag/${tag}`;

    const { data } = await got(pageUrl);
    const $ = load(data);

    const list = $('#category_new li a, .List-4 h3 a')
        .toArray()
        .map((item): DataItem => {
            const $item = $(item);
            return {
                title: $item.attr('title') || $item.text(),
                link: $item.attr('href'),
            };
        });

    const items = await Promise.all(

View on GitHub (pinned to bed535e087)

Solutions

  1. Pass only 'news' or 'sexynews' as domain.
  2. Leave domain unset to default to 'news'.
  3. Extend isValidHost if a new subdomain is introduced.

Example fix

// before
if (!isValidHost(domain)) {
    throw new InvalidParameterError('Invalid domain');
}

// after
const validDomains = ['news', 'sexynews'];
if (!validDomains.includes(domain)) {
    throw new InvalidParameterError(`Invalid domain "${domain}". Valid: ${validDomains.join(', ')}`);
}
Defensive patterns

Strategy: validation

Validate before calling

const validDomains = ['news', 'sexynews'];
if (!validDomains.includes(domain)) {
  throw new InvalidParameterError(`Invalid domain. Valid: ${validDomains.join(', ')}`);
}

Type guard

const isValidDomain = (d: string): d is 'news' | 'sexynews' => d === 'news' || d === 'sexynews';

Prevention

When it happens

Trigger: Supplying a domain other than the two known Gamme subdomains (news, sexynews), or a malformed/empty domain string. The tag parameter itself is not validated here — only the host.

Common situations: Typing the full hostname or URL into the domain field; guessing subdomain names; domain parameter left set to an old value after Gamme consolidated subdomains.

Related errors


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