DIYgod/RSSHub · error · Error

Invalid type: ${type}

Error message

Invalid type: ${type}

What it means

The Gamersky review route mirrors the news route: a type path parameter (default 'pc') is searched in a static idNameMap, and a miss throws 'Invalid type: {type}'. It guards against fetching reviews for an unknown nodeId.

Source

Thrown at lib/routes/gamersky/review.ts:72

    },
    radar: [
        {
            source: ['www.gamersky.com/review'],
            target: '/review',
        },
    ],
    name: '评测',
    maintainers: ['yy4382'],
    description: mdTableBuilder(idNameMap),
    handler,
};

async function handler(ctx: Context) {
    const type = ctx.req.param('type') ?? 'pc';

    const idName = idNameMap.find((item) => item.type === type);
    if (!idName) {
        throw new Error(`Invalid type: ${type}`);
    }

    const response = await getArticleList(idName.nodeId);
    const list = parseArticleList(response);
    const fullTextList = await Promise.all(list.map((item) => getArticle(item)));
    return {
        title: `${idName.name} - 游民星空评测`,
        link: 'https://www.gamersky.com/review',
        item: fullTextList,
    };
}

View on GitHub (pinned to bed535e087)

Solutions

  1. Check the route description table for the valid type codes for reviews specifically.
  2. Update idNameMap if a review section was renamed.
  3. Trim the input before lookup.

Example fix

// before
const idName = idNameMap.find((item) => item.type === type);
if (!idName) {
    throw new Error(`Invalid type: ${type}`);
}

// after
const idName = idNameMap.find((item) => item.type === type.trim());
if (!idName) {
    const valid = idNameMap.map((i) => i.type).join(', ');
    throw new InvalidParameterError(`Invalid type "${type}". Valid: ${valid}`);
}
Defensive patterns

Strategy: validation

Validate before calling

const validTypes = idNameMap.map((i) => i.type);
if (!validTypes.includes(type.trim())) {
  throw new InvalidParameterError(`Invalid type. Valid: ${validTypes.join(', ')}`);
}

Type guard

const isValidType = (t: string): t is string => idNameMap.some((i) => i.type === t);

Prevention

When it happens

Trigger: Requesting /gamersky/review/{type} with a type absent from idNameMap — typo, archived review category, or a value belonging to the news/ent routes.

Common situations: Users conflating review types with news types; Gamersky retiring a review section; casing or whitespace differences in the supplied type.

Related errors


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