{"record":{"id":"ebda103b022b1b82","repo":"DIYgod/RSSHub","slug":"invalid-lang-ebda10","errorCode":null,"errorMessage":"Invalid lang","messagePattern":"Invalid lang","errorType":"validation","errorClass":"InvalidParameterError","httpStatus":503,"severity":"warning","filePath":"lib/routes/ff14/ff14-global.ts","lineNumber":42,"sourceCode":"    handler,\n    description: `Region\n\n| North Ameria | Europe | France | Germany | Japan |\n| ------------ | ------ | ------ | ------- | ----- |\n| na           | eu     | fr     | de      | jp    |\n\nCategory\n\n| all | topics | notices | maintenance | updates | status | developers |\n| --- | ------ | ------- | ----------- | ------- | ------ | ---------- |`,\n};\n\nasync function handler(ctx) {\n    const lang = ctx.req.param('lang');\n    const type = ctx.req.param('type') ?? 'all';\n\n    if (!isValidHost(lang)) {\n        throw new InvalidParameterError('Invalid lang');\n    }\n\n    const response = await got({\n        method: 'get',\n        url: `https://lodestonenews.com/news/${type}?locale=${lang}`,\n    });\n\n    let data;\n    if (type === 'all') {\n        data = [];\n        for (const arr of Object.values(response.data) as unknown[][]) {\n            data = [...data, ...arr];\n        }\n    } else {\n        data = response.data;\n    }\n\n    return {","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/ff14/ff14-global.ts#L24-L60","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const VALID_REGIONS = new Set(['na', 'eu', 'fr', 'de', 'jp']);\n\nfunction validateLang(lang: string | undefined): string {\n    if (!lang || !VALID_REGIONS.has(lang)) {\n        throw new InvalidParameterError(`Invalid region: ${lang}. Valid: na, eu, fr, de, jp`);\n    }\n    return lang;\n}","typeGuard":"type FF14Region = 'na' | 'eu' | 'fr' | 'de' | 'jp';\n\nfunction isFF14Region(lang: string): lang is FF14Region {\n    return ['na', 'eu', 'fr', 'de', 'jp'].includes(lang);\n}","tryCatchPattern":null,"preventionTips":["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."],"tags":["parameter-validation","hostname-validation","invalid-parameter-error","ff14"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}