DIYgod/RSSHub · warning · InvalidParameterError
Invalid category: ${category}
Error message
Invalid category: ${category} What it means
InvalidParameterError thrown by the Plurk Top handler when the category path parameter is not in the allowed set {topReplurks, topFavorites, topResponded}. The route validates against a Set before building the /Stats/{category} URL, so an unknown category never reaches the upstream API.
Source
Thrown at lib/routes/plurk/top.ts:39
supportPodcast: false,
supportScihub: false,
},
name: 'Top',
maintainers: ['TonyRL'],
handler,
description: `| Top Replurks | Top Favorites | Top Responded |
| ------------ | ------------- | ------------- |
| topReplurks | topFavorites | topResponded |
| English | 中文(繁體) |
| ------- | ------------ |
| en | zh |`,
};
async function handler(ctx) {
const { category = 'topReplurks', lang = 'en' } = ctx.req.param();
if (!categoryList.has(category)) {
throw new InvalidParameterError(`Invalid category: ${category}`);
}
const { data: apiResponse } = await got(`${baseUrl}/Stats/${category}`, {
searchParams: {
period: 'day',
lang,
limit: ctx.req.query('limit') ? Number(ctx.req.query('limit')) : 90,
},
});
const items = await Promise.all(apiResponse.stats.map((item) => item[1]).map((item) => getPlurk(`plurk:${item.plurk_id}`, item, item.owner.display_name)));
return {
title: 'Top Plurk - Plurk',
image: 'https://s.plurk.com/2c1574c02566f3b06e91.png',
link: `${baseUrl}/top#${category}`,
item: items,
language: lang,View on GitHub (pinned to bed535e087)
Solutions
- Use one of the documented categories: topReplurks, topFavorites, or topResponded (case-sensitive).
- Omit the category to accept the default (topReplurks).
- If subscribing from a docs example, copy the value verbatim.
- Update any stale RSS client URLs that reference a renamed/removed category.
Example fix
// before: /plurk/top/topReplurk // after: /plurk/top/topReplurks
Defensive patterns
Strategy: validation
Validate before calling
const VALID_CATEGORIES = new Set(['topReplurks', 'topFavorites', 'topResponded']);
function isValidCategory(c: string): c is 'topReplurks' | 'topFavorites' | 'topResponded' {
return VALID_CATEGORIES.has(c);
}
// before building the request:
if (!isValidCategory(category)) {
// reject with the allowed list
} Type guard
const isValidCategory = (c: unknown): c is 'topReplurks' | 'topFavorites' | 'topResponded' => typeof c === 'string' && new Set(['topReplurks', 'topFavorites', 'topResponded']).has(c as any);
Try / catch
try {
// plurk top handler
} catch (e) {
if (e instanceof InvalidParameterError && /Invalid category/.test(e.message)) {
// surface the three valid categories to the user
}
} Prevention
- Constrain category input to the documented Set before requesting.
- Default the category when omitted to avoid typos.
- Keep the category list and the route description table in sync.
When it happens
Trigger: Passing a category value outside the three valid ones in /plurk/top/:category?/:lang?, e.g. a typo like 'topReplurk' (missing s), 'topLikes', or a localized string.
Common situations: User mistypes the category; copies a value from outdated docs; uses a singular form; passes an arbitrary string hoping for a category.
Related errors
- Invalid category
- At least one valid search parameter is required
- 无法检测 Discuz 版本,请在路由中指定版本参数,如 /discuz/x/ 或 /discuz/7/
- 通知类型${typeParam}未定义
- Unsupported language: ${language}
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/05f396bdf611ec82.
Report an issue: GitHub.