DIYgod/RSSHub · error · Error
Invalid type: ${type}
Error message
Invalid type: ${type} What it means
The Gamersky news route accepts a type path parameter (default 'pc') and searches a static idNameMap array for a matching type. If no entry has that type, the route throws 'Invalid type: {type}'. This prevents constructing a request with an unknown nodeId.
Source
Thrown at lib/routes/gamersky/news.ts:82
},
radar: [
{
source: ['www.gamersky.com/news'],
target: '/news',
},
],
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/news',
item: fullTextList,
};
}
View on GitHub (pinned to bed535e087)
Solutions
- Consult the route description (mdTableBuilder of idNameMap) for the exact valid type strings.
- If the desired section was renamed, update idNameMap or switch to the new type code.
- Normalize the input (trim) before the find() call.
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
- Include valid types in the error message. Trim input before the find() call. Differentiate this route's types from ent/review types in docs.
When it happens
Trigger: Requesting /gamersky/news/{type} with a type not present in idNameMap — a typo, an archived news section, or a value intended for a different Gamersky route (ent/review).
Common situations: Users guessing type names; Gamersky restructuring news sections; copy-pasting a type from documentation for a different route.
Related errors
- Invalid type: ${category}
- Invalid type: ${type}
- Bad timeRange range. See <a href="https://docs.rsshub.app/ro
- This category does not exist. Please refer to the documentat
- Invalid category Id: ${categoryId}
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/e753c59e9bdd9e43.
Report an issue: GitHub.