DIYgod/RSSHub · warning · InvalidParameterError
Invalid language
Error message
Invalid language
What it means
Thrown by the MyFigureCollection activity route when the :language path parameter is non-empty and fails the isValidHost regex check (a single-label hostname pattern: starts alphanumeric, contains only alphanumeric/hyphen, max 63 chars). The language is used as a subdomain prefix (e.g. {language}.myfigurecollection.net), so it must be a valid DNS label.
Source
Thrown at lib/routes/myfigurecollection/activity.tsx:76
| nl | Nederlands |
| no | Norsk |
| pl | Polski |
| pt | Português |
| ru | Русский |
| sv | Svenska |
| zh | 中文 |`,
};
async function handler(ctx) {
const category = ctx.req.param('category') ?? '-1';
const language = ctx.req.param('language') ?? '';
const latestAdditions = ctx.req.param('latestAdditions') ?? '1';
const latestEdits = ctx.req.param('latestEdits') ?? '1';
const latestAlerts = ctx.req.param('latestAlerts') ?? '1';
const latestPictures = ctx.req.param('latestPictures') ?? '1';
if (language && !isValidHost(language)) {
throw new InvalidParameterError('Invalid language');
}
const rootUrl = `https://${language === 'en' || language === '' ? '' : `${language}.`}myfigurecollection.net`;
const currentUrl = `${rootUrl}/browse.v4.php?mode=activity&latestAdditions=${latestAdditions}&latestEdits=${latestEdits}&latestAlerts=${latestAlerts}&latestPictures=${latestPictures}&rootId=${category}`;
const response = await got({
method: 'get',
url: currentUrl,
});
const $ = load(response.data);
const items = $('.activity-wrapper')
.toArray()
.map((item) => {
const $item = $(item);
return {View on GitHub (pinned to bed535e087)
Solutions
- Use one of the documented two-letter language codes: en, de, es, fi, fr, it, ja, nl, no, pl, pt, ru, sv, zh (or omit for en).
- Avoid dots, underscores, spaces, or non-ASCII characters in the language segment.
- List valid codes in the error message for discoverability.
Example fix
// before
if (language && !isValidHost(language)) {
throw new InvalidParameterError('Invalid language');
}
// after — explicit allowlist with helpful message
const allowedLangs = ['', 'en', 'de', 'es', 'fi', 'fr', 'it', 'ja', 'nl', 'no', 'pl', 'pt', 'ru', 'sv', 'zh'];
if (language && !allowedLangs.includes(language.toLowerCase())) {
throw new InvalidParameterError(`Invalid language '${language}'. Supported: ${allowedLangs.filter(Boolean).join(', ')}`);
} Defensive patterns
Strategy: validation
Validate before calling
const MFC_LANGUAGES = ['', 'en', 'de', 'es', 'fi', 'fr', 'it', 'ja', 'nl', 'no', 'pl', 'pt', 'ru', 'sv', 'zh'];
const language = (ctx.req.param('language') ?? '').toLowerCase();
if (language && !MFC_LANGUAGES.includes(language)) {
throw new InvalidParameterError(`Invalid language '${language}'. Supported: ${MFC_LANGUAGES.filter(Boolean).join(', ')}`);
} Type guard
const MFC_LANGS = new Set(['', 'en', 'de', 'es', 'fi', 'fr', 'it', 'ja', 'nl', 'no', 'pl', 'pt', 'ru', 'sv', 'zh']);
function isMfcLanguage(l: string): boolean {
return MFC_LANGS.has(l.toLowerCase());
} Prevention
- Use an explicit allowlist of valid language codes instead of the generic hostname regex.
- Share the allowlist between this route and the sibling index route.
- Normalize case before validation.
- Include the supported list in the error message.
When it happens
Trigger: Passing a language code with invalid hostname characters: dots (e.g. 'zh-CN'), underscores, spaces, or special chars. Passing a value longer than 63 characters. Passing an empty-but-truthy value like a single space. Valid codes (en, de, es, fr, ja, zh, etc.) pass because they are clean DNS labels.
Common situations: User passes 'zh-CN' (with hyphen-region) thinking it is an IETF tag — the hyphen makes it 'zh' label + invalid second label conceptually, but actually the regex allows hyphens so 'zh-CN' would pass; the real failure is codes with dots, underscores, or non-ASCII. User passes a full hostname like 'en.myfigurecollection.net'. User passes uppercase which actually passes (regex is case-insensitive).
Related errors
- Invalid language
- Invalid language
- Invalid language
- Bad timeRange range. See <a href="https://docs.rsshub.app/ro
- Bad parameter. See <a href="https://docs.rsshub.app/routes/g
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/9f578c3c5c3356bb.
Report an issue: GitHub.