DIYgod/RSSHub · warning · InvalidParameterError
Unsupported model: ${model}
Error message
Unsupported model: ${model} What it means
processFeed dispatches on a model string ('channel', 'tags', 'author') via a switch. The default branch throws InvalidParameterError for any other model value. This is an internal routing error: model comes from the route definition, not (usually) directly from user input, so an unsupported model means a route was wired to processFeed with an unhandled model.
Source
Thrown at lib/routes/theinitium/utils.ts:239
break;
}
case 'tags': {
const tagSlug = language ? applyLanguageToTagSlug(type, language) : type;
filter = `tag:${tagSlug}`;
listLink = `https://theinitium.com/tag/${type}/`;
feedName = type;
break;
}
case 'author': {
// Author slugs also have -zh-hans suffixed versions for simplified Chinese
const authorSlug = language === 'zh-hans' ? `${type}-zh-hans` : type;
filter = `author:${authorSlug}`;
listLink = `https://theinitium.com/author/${type}/`;
feedName = type;
break;
}
default:
throw new InvalidParameterError(`Unsupported model: ${model}`);
}
const cacheKey = `theinitium:ghost:${model}:${type}:${language}`;
// Use routeExpire (5 min default) and refresh=false so cache actually expires
const data = (await cache.tryGet(
cacheKey,
async () => {
const params: Record<string, string> = {
include: 'tags,authors',
limit: '20',
};
if (filter) {
params.filter = filter;
}
return await ghostFetch('posts', params);
},
config.cache.routeExpire,
falseView on GitHub (pinned to bed535e087)
Solutions
- Add a case in processFeed's switch for the new model, or route the new subscription through an existing model.
- Ensure every route that calls processFeed passes one of the supported model literals.
- Make the model a union type (type Model = 'channel'|'tags'|'author') so TypeScript flags invalid callers at compile time.
Example fix
// before
switch (model) {
case 'channel': ...
case 'tags': ...
case 'author': ...
default: throw new InvalidParameterError(`Unsupported model: ${model}`);
}
// after: narrow with a union type so invalid models are a compile error
type FeedModel = 'channel' | 'tags' | 'author';
export const processFeed = async (model: FeedModel, ctx: Context) => {
switch (model) {
case 'channel': ...
case 'tags': ...
case 'author': ...
}
}; Defensive patterns
Strategy: type-guard
Validate before calling
type FeedModel = 'channel' | 'tags' | 'author';
const SUPPORTED_MODELS = new Set<FeedModel>(['channel', 'tags', 'author']);
function isFeedModel(m: string): m is FeedModel {
return SUPPORTED_MODELS.has(m as FeedModel);
}
// only call processFeed when isFeedModel(model) Type guard
function isFeedModel(m: string): m is 'channel' | 'tags' | 'author' {
return m === 'channel' || m === 'tags' || m === 'author';
} Try / catch
try {
return await processFeed(model, ctx);
} catch (e) {
if (e instanceof InvalidParameterError && /Unsupported model/.test(e.message)) {
// this is a programmer error; surface it loudly in logs
throw new Error(`Route wired to processFeed with bad model "${model}"`);
}
throw e;
} Prevention
- Model is internal: type it as a union so invalid callers fail at compile time.
- Add a switch case whenever a new subscription type is introduced.
- Audit route definitions that call processFeed to ensure they pass a supported model.
When it happens
Trigger: A theinitium route registers with a model not in {channel, tags, author} (e.g. 'topic' or 'section') and routes to processFeed; the switch falls through to default.
Common situations: Adding a new subscription type and forgetting to add its case to the switch; refactoring route definitions and changing the model string; copy-paste route wiring that passes a wrong literal.
Related errors
- Unknown category: ${category}. Supported: ${Object.keys(APP_
- Bad timeRange range. See <a href="https://docs.rsshub.app/ro
- Bad parameter. See <a href="https://docs.rsshub.app/routes/g
- Invalid city
- Invalid channel name
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/ca79e0c66a17a346.
Report an issue: GitHub.