DIYgod/RSSHub · error · InvalidParameterError
Invalid domain
Error message
Invalid domain
What it means
The Gamme category route builds a subdomain from the user-supplied domain parameter (e.g. news, sexynews) and validates it with isValidHost before constructing https://{domain}.gamme.com.tw. If the host is not whitelisted/valid, it throws InvalidParameterError('Invalid domain') — a 400-class error that tells the user the parameter is rejected, not the server.
Source
Thrown at lib/routes/gamme/category.ts:26
import { isValidHost } from '@/utils/valid-host';
export const route: Route = {
path: '/:domain/:category?',
categories: ['new-media'],
example: '/gamme/news',
parameters: {
domain: '網站,`news` 為宅宅新聞,`sexynews` 為西斯新聞',
category: '分類名,可在 URL 找到,預設為全部',
},
name: '分類',
maintainers: ['TonyRL'],
handler,
};
async function handler(ctx) {
const { domain = 'news', category } = ctx.req.param();
if (!isValidHost(domain)) {
throw new InvalidParameterError('Invalid domain');
}
const baseUrl = `https://${domain}.gamme.com.tw`;
const feed = await parser.parseURL(`${baseUrl + (category ? `/category/${category}` : '')}/feed`);
const items = await Promise.all(
feed.items.map((item) =>
cache.tryGet(item.link!, async () => {
const { data } = await got(item.link);
const $ = load(data);
$('.entry img').each((_, img) => {
if (!(img.attribs['data-original'] || img.attribs['data-src'])) {
return;
}
img.attribs.src = img.attribs['data-original'] || img.attribs['data-src'];
delete img.attribs['data-original'];
delete img.attribs['data-src'];View on GitHub (pinned to bed535e087)
Solutions
- Use only 'news' (宅宅新聞) or 'sexynews' (西斯新聞) as the domain parameter.
- If Gamme adds a new subdomain, extend the isValidHost whitelist.
- Omit the parameter to accept the default 'news'.
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
- Whitelist the exact subdomain labels rather than a loose host check. Default to 'news' when the parameter is omitted. Never interpolate raw user input into a URL without validation.
When it happens
Trigger: Passing a domain value that is neither 'news' nor 'sexynews' (the two known Gamme subdomains), or a value with characters that fail isValidHost's check. Because the domain is interpolated directly into a URL, invalid input could cause a malformed request, hence the guard.
Common situations: Users typing the full URL instead of the subdomain label; typos like 'new'; attempting a subdomain that Gamme does not operate; injection-style input.
Related errors
- Invalid domain
- Invalid type parameter
- unknown site: ${site}
- Invalid type parameter
- Invalid category: ${category}
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/498db34aea4ccf19.
Report an issue: GitHub.