DIYgod/RSSHub · warning · TypeError

Language parameter is not valid. Please use one of the follo

Error message

Language parameter is not valid. Please use one of the following: ${SUPPORTED_LANGUAGES.join(', ')}

What it means

Thrown by the kurogames Wuthering Waves (鸣潮) news handler as a TypeError when the language path param fails isValidLanguage(). Supported languages come from SUPPORTED_LANGUAGES (en, jp, kr, zh, zh-tw, es, fr, de per the route description). The error message lists all valid codes so the caller can correct the input.

Source

Thrown at lib/routes/kurogames/wutheringwaves/news.ts:53

|----------|--------------|
| English  | en           |
| 日本語    | jp           |
| 한국어     | kr           |
| 简体中文   | zh (default) |
| 繁體中文   | zh-tw        |
| Español  | es           |
| Français | fr           |
| Deutsch  | de           |
    `,
    async handler(ctx) {
        const limitParam = ctx.req.query(Parameter.Limit);
        const languageParam = ctx.req.param(Parameter.Language);

        const limit = parseInteger(limitParam, 30);
        const language = languageParam || Language.Chinese;

        if (!isValidLanguage(language)) {
            throw new TypeError(`Language parameter is not valid. Please use one of the following: ${SUPPORTED_LANGUAGES.join(', ')}`);
        }

        const articles = await fetchArticles(language);
        const filteredArticles = articles.filter((a) => a.articleType !== 0).slice(0, limit);

        const item = await Promise.all(
            filteredArticles.map((article) => {
                const contentUrl = getArticleContentLink(language, article.articleId);
                const item: DataItem = {
                    title: article.articleTitle,
                    pubDate: timezone(parseDate(article.createTime), 8),
                    link: getArticleLink(language, article.articleId),
                };

                return cache.tryGet(`wutheringwaves:${language}:${article.articleId}`, async () => {
                    const articleDetails = await ofetch<Article>(contentUrl, { query: { t: Date.now() } });
                    // Article content may not always be available, e.g: https://wutheringwaves.kurogames.com/zh-tw/main/news/detail/2596
                    const articleContent = articleDetails.articleContent ?? '';

View on GitHub (pinned to bed535e087)

Solutions

  1. Use one of the documented codes: en, jp, kr, zh, zh-tw, es, fr, de
  2. Omit the param entirely to get the default (zh)
  3. If you need a new language, add it to SUPPORTED_LANGUAGES and Language enum in lib/routes/kurogames/wutheringwaves/constants.ts
  4. Verify whether isValidLanguage is case-sensitive and match the case of the listed codes

Example fix

// before
const language = languageParam || Language.Chinese;
if (!isValidLanguage(language)) {
    throw new TypeError(`Language parameter is not valid. Please use one of the following: ${SUPPORTED_LANGUAGES.join(', ')}`);
}
// after — normalize case before rejecting
const language = (languageParam || Language.Chinese).toLowerCase();
if (!isValidLanguage(language)) {
    throw new TypeError(`Language '${languageParam}' is not valid. Use one of: ${SUPPORTED_LANGUAGES.join(', ')}`);
}
Defensive patterns

Strategy: type-guard

Validate before calling

import { SUPPORTED_LANGUAGES } from './constants';
function isValidLang(code: string | undefined): boolean {
  return code === undefined || SUPPORTED_LANGUAGES.includes(code as any);
}
if (!isValidLang(ctx.req.param(Parameter.Language))) {
  return ctx.json({ error: `language must be one of ${SUPPORTED_LANGUAGES.join(', ')}` }, 400);
}

Type guard

import { SUPPORTED_LANGUAGES, Language } from './constants';
function isSupportedLanguage(v: unknown): v is Language {
  return typeof v === 'string' && (SUPPORTED_LANGUAGES as readonly string[]).includes(v);
}

Try / catch

try { return await route.handler(ctx); }
catch (e) {
  if (e instanceof TypeError && /Language parameter/.test(e.message)) {
    return ctx.json({ error: e.message, allowed: SUPPORTED_LANGUAGES }, 400);
  }
  throw e;
}

Prevention

When it happens

Trigger: Request to /kurogames/wutheringwaves/news/<lang> where <lang> is not in SUPPORTED_LANGUAGES — e.g. /news/english, /news/zhs, /news/us, or a typo. Omitting the param is safe (defaults to Language.Chinese).

Common situations: User supplies a full language name instead of the code; uses an ISO code not in the set (e.g. 'zh-cn' instead of 'zh', 'ja' instead of 'jp'); typo; case mismatch if isValidLanguage is case-sensitive.

Related errors


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