DIYgod/RSSHub · error · InvalidParameterError
Invalid type: ${type}
Error message
Invalid type: ${type} What it means
The Gamebase route supports a `type` path parameter validated against a `types` map containing only `newslist` and `r18list`. An `hasOwnProperty` check throws InvalidParameterError for any other value before the API call is made.
Source
Thrown at lib/routes/gamebase/news.tsx:41
{images?.length
? images.map((image) =>
image?.src ? (
<figure key={image.src}>
<img src={image.src} alt={image.alt} />
</figure>
) : null
)
: null}
{intro ? <blockquote>{intro}</blockquote> : null}
{description ? <>{raw(description)}</> : null}
</>
);
export const handler = async (ctx: Context): Promise<Data> => {
const { type = 'newslist', category = 'all' } = ctx.req.param();
if (!types.hasOwnProperty(type)) {
throw new InvalidParameterError(`Invalid type: ${type}`);
}
const limit = Number(ctx.req.query('limit') ?? '30');
const baseUrl = 'https://news.gamebase.com.tw';
const targetUrl: string = new URL(`news${category === 'all' ? '' : `/newslist?type=${category}`}`, baseUrl).href;
const apiBaseUrl = 'https://api.gamebase.com.tw';
const apiUrl: string = new URL('api/news/getNewsList', apiBaseUrl).href;
const response = await ofetch(apiUrl, {
method: 'post',
body: {
GB_type: types[type],
category,
page: 1,
},
});
View on GitHub (pinned to bed535e087)
Solutions
- Use `newslist` (default) or `r18list`.
- Omit the type segment to fall back to `newslist`.
Example fix
// before // /gamebase/news/latest // after // /gamebase/news/newslist
Defensive patterns
Strategy: validation
Validate before calling
const types = { newslist: 'newsList', r18list: 'newsPornList' } as const;
function isValidType(type: string): type is keyof typeof types {
return Object.prototype.hasOwnProperty.call(types, type);
} Type guard
function isValidType(type: string): type is keyof typeof types {
return Object.prototype.hasOwnProperty.call(types, type);
} Prevention
- Use a `const` object + keyof narrowing so the compiler tracks valid values.
- Document the two types in the route description.
When it happens
Trigger: `/gamebase/news/<type>` where <type> is not `newslist` or `r18list` — e.g. `/gamebase/news/latest`, `/gamebase/news/top`.
Common situations: Guessing a type value; typos; omitting the segment is safe (defaults to newslist).
Related errors
- 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}
- Invalid sort type: ${sortType}
- Invalid time range: ${timeRange}
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/08c6d49799bc0946.
Report an issue: GitHub.