DIYgod/RSSHub · warning · InvalidParameterError
Invalid lang
Error message
Invalid lang
What it means
Thrown as an `InvalidParameterError` when the `lang` path parameter fails `isValidHost()`. The regex `/^[\dA-Z](?:[\dA-Z-]{0,61}[\dA-Z])?$/i` validates hostname-compatible strings. The valid region codes (`na`, `eu`, `fr`, `de`, `jp`) all pass this check, so the error fires only on genuinely malformed input — not on a wrong-but-valid region code. Note: the route does NOT validate that `lang` is one of the five supported regions; it only checks the string is hostname-safe. An unsupported but hostname-valid value like `uk` would pass validation but may produce an empty or broken feed from lodestonenews.com.
Source
Thrown at lib/routes/ff14/ff14-global.ts:42
handler,
description: `Region
| North Ameria | Europe | France | Germany | Japan |
| ------------ | ------ | ------ | ------- | ----- |
| na | eu | fr | de | jp |
Category
| all | topics | notices | maintenance | updates | status | developers |
| --- | ------ | ------- | ----------- | ------- | ------ | ---------- |`,
};
async function handler(ctx) {
const lang = ctx.req.param('lang');
const type = ctx.req.param('type') ?? 'all';
if (!isValidHost(lang)) {
throw new InvalidParameterError('Invalid lang');
}
const response = await got({
method: 'get',
url: `https://lodestonenews.com/news/${type}?locale=${lang}`,
});
let data;
if (type === 'all') {
data = [];
for (const arr of Object.values(response.data) as unknown[][]) {
data = [...data, ...arr];
}
} else {
data = response.data;
}
return {View on GitHub (pinned to bed535e087)
Solutions
- Use one of the five valid region codes: `na` (North America), `eu` (Europe), `fr` (France), `de` (Germany), `jp` (Japan).
- Ensure the parameter is a plain alphanumeric string with no special characters.
- Note: passing an unsupported but valid-looking code (e.g., `uk`) won't throw but may return empty results — always use the documented regions.
Defensive patterns
Strategy: validation
Validate before calling
const VALID_REGIONS = new Set(['na', 'eu', 'fr', 'de', 'jp']);
function validateLang(lang: string | undefined): string {
if (!lang || !VALID_REGIONS.has(lang)) {
throw new InvalidParameterError(`Invalid region: ${lang}. Valid: na, eu, fr, de, jp`);
}
return lang;
} Type guard
type FF14Region = 'na' | 'eu' | 'fr' | 'de' | 'jp';
function isFF14Region(lang: string): lang is FF14Region {
return ['na', 'eu', 'fr', 'de', 'jp'].includes(lang);
} Prevention
- Use only the five documented region codes: na, eu, fr, de, jp.
- Note that the current validation only checks hostname safety, not semantic validity — an unsupported code like 'uk' would pass but return empty results.
- Consider adding a Set-based enum check alongside the hostname validation for stronger guarantees.
When it happens
Trigger: A user passes a `lang` containing invalid hostname characters — e.g., `en-us` (hyphen is allowed but the regex requires the full string to match), `na.eu`, or a path segment with slashes. The check is purely structural, not semantic.
Common situations: User passes a locale code with dots or underscores. A URL routing issue injects unexpected characters. The user guesses a region code with special characters.
Related errors
- Invalid host
- Invalid user name
- Bad category. See <a href="https://docs.rsshub.app/routes/ne
- Invalid language: ${lang}
- Invalid type: ${type}
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/ebda103b022b1b82.
Report an issue: GitHub.