DIYgod/RSSHub · warning · Error
Invalid language: . Allowed values are
Error message
Invalid language: ${language}. Allowed values are: ${[...validLanguages].join(', ')} What it means
Thrown by the bandisoft history route when the :language path parameter is not one of the values in languageOptions (en, cn, tw, jp, ru, es, fr, de, it, sk, uk, be, da, pl, br, cs, nl, sl, tr, th, gr, uz, ro, kr). The whitelist is built from languageOptions and the error enumerates every accepted code.
Solutions
- Pick a code from the error message's allowed list (these map 1:1 to {lang}.bandisoft.com subdomains).
- When adding a locale, append it to languageOptions so validation, the example, and the subdomain construction stay in sync.
Defensive patterns
Strategy: validation
Validate before calling
const VALID_LANGS = new Set(languageOptions.map((o) => o.value));
if (!VALID_LANGS.has(language)) {
throw new InvalidParameterError(`Invalid language: ${language}. Allowed: ${[...VALID_LANGS].join(', ')}`);
} Type guard
function isBandisoftLanguage(v: string): boolean {
return languageOptions.some((o) => o.value === v);
} Prevention
- Derive the route example and validation from the same languageOptions array.
- Document that language maps 1:1 to a {lang}.bandisoft.com subdomain.
When it happens
Trigger: Calling the route with a language code outside the supported set, e.g. 'pt' instead of 'br', or a two-letter code Bandisoft does not host a subdomain for.
Common situations: User supplies an ISO code Bandisoft doesn't use; case mismatch; doc lists a removed locale.
Related errors
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/bfae3f57b14271b9.
Report an issue: GitHub.
Appendix: source
Thrown at lib/routes/bandisoft/history.ts:142
label: '한국어',
value: 'kr',
},
];
export const handler = async (ctx: Context): Promise<Data> => {
const { id = 'bandizip', language = 'en' } = ctx.req.param();
const limit = Number(ctx.req.query('limit') ?? '500');
const validIds = new Set<string>(idOptions.map((option) => option.value));
if (!validIds.has(id)) {
throw new Error(`Invalid id: ${id}. Allowed values are: ${[...validIds].join(', ')}`);
}
const validLanguages = new Set<string>(languageOptions.map((option) => option.value));
if (!validLanguages.has(language)) {
throw new Error(`Invalid language: ${language}. Allowed values are: ${[...validLanguages].join(', ')}`);
}
const baseUrl = `https://${language}.bandisoft.com`;
const targetUrl: string = new URL(`${id}/history/`, baseUrl).href;
const response = await ofetch(targetUrl);
const $: CheerioAPI = load(response);
const lang = $('html').attr('lang') ?? 'en';
const author: string | undefined = $('meta[name="author"]').attr('content');
const items: DataItem[] = $('div.row')
.slice(0, limit)
.toArray()
.map((el) => {
const $el: Cheerio<Element> = $(el);
const version: string | undefined = $el.find('div.cell1').text();
const pubDateStr: string | undefined = $el.find('div.cell2').text();View on GitHub (pinned to bed535e087)