DIYgod/RSSHub · warning

Invalid lang

Error message

Invalid lang

What it means

Thrown by the engadget home route when the resolved `lang` is not in the allowLang set {chinese, cn, us, japanese, www}. Note 'us' is internally remapped to 'www', but any other value (e.g. 'uk', 'de', 'fr') is rejected.

Source

Thrown at lib/routes-deprecated/engadget/home.js:9

const got = require('@/utils/got');
const cheerio = require('cheerio');
const parser = require('@/utils/rss-parser');
const allowLang = new Set(['chinese', 'cn', 'us', 'japanese', 'www']);

module.exports = async (ctx) => {
    const lang = ctx.params.lang === 'us' ? 'www' : ctx.params.lang || 'cn';
    if (!allowLang.has(lang)) {
        throw new Error('Invalid lang');
    }
    const rssUrl = `https://${lang}.engadget.com/rss.xml`;
    const feed = await parser.parseURL(rssUrl);

    const ProcessFeed = (data) => {
        const $ = cheerio.load(data);
        if (ctx.params.lang === 'us') {
            $('div#engadget-article-footer').remove();
            $('div#right-ads-rail').remove();
            $('.t-meta.c-gray-3.mb-35').remove();
            return $('div#page_body').html();
        } else {
            $('span#end-legacy-contents').remove();
            $('#post-slideshow figcaption').remove();
            $('#post-slideshow div.pagination button').remove();
            $('#post-slideshow img.scrollview-image-embedded').each((i, el) => {
                $(el).attr('src', $(el).data('wf-src'));
            });

View on GitHub (pinned to bed535e087)

Solutions

  1. Use one of: chinese, cn, us, japanese (or omit for the cn default).
  2. Do not request unsupported locales; Engadget only publishes those variants.

Example fix

// before
/engadget/usa
// after
/engadget/us
Defensive patterns

Strategy: type-guard

Validate before calling

const allowLang = new Set(['chinese','cn','us','japanese','www']);
if (!allowLang.has(lang)) throw new Error('Invalid lang');

Type guard

const isAllowedLang = (l: unknown): boolean =>
  typeof l === 'string' && allowLang.has(l);

Prevention

When it happens

Trigger: Request to /engadget/:lang with a lang not in the allowLang set.

Common situations: User requests a regional variant Engadget does not actually publish via RSS; typo; passing 'usa' instead of 'us'.

Related errors


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