DIYgod/RSSHub · error · Error

Unsupported language: ${language}

Error message

Unsupported language: ${language}

What it means

Thrown by the Geocaching blogs route when the ':language' path parameter is not one of the supported values. The route checks three branches: 'en' (English, excludes other categories), any key in languageToCategory (de, fr, es, nl, cs), and 'all' (no filtering). Any other value hits the else branch and throws.

Source

Thrown at lib/routes/geocaching/blogs.ts:68

        per_page: number;
        _embed: number;
        _fields: string;
        categories_exclude?: string;
        categories?: number;
    } = {
        per_page: ctx.req.query('limit') ?? 20,
        _embed: 1,
        _fields: ['id', 'title', 'link', 'guid', 'content', 'date_gmt', 'modified_gmt', '_embedded', '_links'].join(','),
    };

    if (language === 'en') {
        searchParams.categories_exclude = Object.values(languageToCategory).join(',');
    } else if (Object.hasOwn(languageToCategory, language)) {
        searchParams.categories = languageToCategory[language];
    } else if (language === 'all') {
        // do nothing
    } else {
        throw new Error(`Unsupported language: ${language}`);
    }

    // console.log(searchParams);

    const { data: response } = await got(`${baseUrl}/blog/wp-json/wp/v2/posts`, { searchParams });
    const items = response.map((item) => {
        const media = item._embedded['wp:featuredmedia'][0];
        const mediaDetails = media?.media_details;
        const mediaSize = mediaDetails?.sizes.large || mediaDetails?.sizes.full;
        return {
            title: item.title.rendered.trim(),
            link: item.link,
            guid: item.guid.rendered,
            description: item.content.rendered,
            pubDate: parseDate(item.date_gmt),
            updated: parseDate(item.modified_gmt),
            author: item._embedded.author[0].name,
            category: item._embedded['wp:term'][0].map((category) => category.name.trim()),

View on GitHub (pinned to bed535e087)

Solutions

  1. Use one of the seven valid language codes: en, de, fr, es, nl, cs, all
  2. Omit the language parameter to default to 'en'
  3. Check the route parameters declaration in the source for the authoritative options list

Example fix

// before
} else {
    throw new Error(`Unsupported language: ${language}`);
}

// after (use InvalidParameterError and list valid values)
import InvalidParameterError from '@/errors/types/invalid-parameter';
// ...
} else {
    throw new InvalidParameterError(`Unsupported language '${language}'. Supported: en, de, fr, es, nl, cs, all`);
}
Defensive patterns

Strategy: validation

Validate before calling

const VALID_LANGUAGES = ['en', 'de', 'fr', 'es', 'nl', 'cs', 'all'];
const language = ctx.req.param('language') ?? 'en';
if (!VALID_LANGUAGES.includes(language)) {
    throw new InvalidParameterError(`Unsupported language '${language}'. Supported: ${VALID_LANGUAGES.join(', ')}`);
}

Type guard

function isSupportedLanguage(lang: string): lang is 'en' | 'de' | 'fr' | 'es' | 'nl' | 'cs' | 'all' {
    return lang === 'en' || lang === 'all' || Object.hasOwn(languageToCategory, lang);
}

Prevention

When it happens

Trigger: A request to /geocaching/blogs/<language> where <language> is not 'en', 'de', 'fr', 'es', 'nl', 'cs', or 'all'. The route parameters declaration also lists these as options, so the RSSHub API UI typically constrains input, but direct URL access bypasses that.

Common situations: Using a language code that isn't supported (e.g., 'it' for Italian, 'pt' for Portuguese); uppercase variants ('EN', 'DE'); typos; using 'english' instead of 'en'.

Related errors


AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12). Data as JSON: /api/errors/323e8fe7ffbfdd56. Report an issue: GitHub.