DIYgod/RSSHub · warning · InvalidParameterError
Invalid type: ${type}
Error message
Invalid type: ${type} What it means
Thrown as an `InvalidParameterError` when the `type` path parameter is not in the allowed set `{'latest', 'game-updates', 'news-article'}`. This is pre-flight validation that fires before the EA drop-api call, producing an HTTP 400-level response.
Source
Thrown at lib/routes/ea/apex-news.ts:29
html: true,
breaks: true,
});
const langEnum = new Set(['zh-hant', 'en']);
const typeEnum = new Set(['latest', 'game-updates', 'news-article']);
async function handler(ctx) {
const { lang = 'en', type = 'latest' } = ctx.req.param();
const apiParams = new URLSearchParams({
limit: '13',
gameSlug: 'apex-legends',
offset: '0',
});
if (!langEnum.has(lang)) {
throw new InvalidParameterError(`Invalid language: ${lang}`);
}
if (!typeEnum.has(type)) {
throw new InvalidParameterError(`Invalid type: ${type}`);
}
if (type !== 'latest') {
apiParams.append('typeSlug', type);
}
if (lang !== 'en') {
apiParams.append('locale', lang);
}
const apiUrl = `https://drop-api.ea.com/news-articles/pagination?${apiParams}`;
const newsItems = await ofetch(apiUrl);
type NewsItem = DataItem & {
slug: string;
};
const allItems: NewsItem[] = [newsItems.featured, ...newsItems.items].filter(Boolean).map((item) => ({
title: item.title,
description: item.summary,
link: `https://www.ea.com${lang === 'en' ? '/' : '/' + lang + '/'}games/apex-legends/apex-legends/news/${item.slug}`,
pubDate: parseDate(item.publishingDate),View on GitHub (pinned to bed535e087)
Solutions
- Use one of the three supported values: `latest`, `game-updates`, or `news-article`.
- Omit the type parameter entirely to default to `latest` (all categories).
- Check the route definition's `parameters.type.options` for the authoritative list.
Defensive patterns
Strategy: validation
Validate before calling
const SUPPORTED_TYPES = new Set(['latest', 'game-updates', 'news-article']);
function validateType(type: string | undefined): string {
const resolved = type ?? 'latest';
if (!SUPPORTED_TYPES.has(resolved)) {
throw new InvalidParameterError(`Invalid type: ${type}. Supported: latest, game-updates, news-article`);
}
return resolved;
} Type guard
function isSupportedType(type: string): type is 'latest' | 'game-updates' | 'news-article' {
return type === 'latest' || type === 'game-updates' || type === 'news-article';
} Prevention
- Always check the route's parameter options for the authoritative list of valid values.
- Default to 'latest' (all categories) when the type parameter is omitted.
- Use the enum Set check early in the handler, before building API params.
When it happens
Trigger: A user requests `/ea/apex-news/<lang>/<type>` where `<type>` is not one of the three valid values — for example `news`, `updates`, `patch-notes`, or an empty/misspelled string. The typeEnum Set check fails immediately.
Common situations: User guesses a category slug from the EA website that is not supported by this route. A third-party integration passes a free-text type value. The user confuses the EA website's navigation labels with the route's accepted values.
Related errors
- Invalid language: ${lang}
- No category '${category}'.
- Bad category. See <a href="https://docs.rsshub.app/routes/ne
- Invalid host
- Invalid user name
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/f67e298e02122ad0.
Report an issue: GitHub.