DIYgod/RSSHub · warning · InvalidParameterError
Bad category. See <a href="https://docs.rsshub.app/routes/fi
Error message
Bad category. See <a href="https://docs.rsshub.app/routes/finance#cai-lian-she-shen-du">docs</a>
What it means
Thrown by the CLS (CaiLianShe) depth route when `category` is not a key in the `categories` map. Valid keys (numeric strings): 1000, 1003, 1135, 1007, 1005, 1118, 1110, 1006, 1032, 1119, 1111, 1127, 1160, 1124, 1176. Defaults to '1000' when omitted. Correctly uses `InvalidParameterError` and links to docs. Note the message contains raw HTML (`<a href=...>`).
Source
Thrown at lib/routes/cls/depth.ts:58
supportPodcast: false,
supportScihub: false,
},
name: '深度',
maintainers: ['nczitzk'],
handler,
description: `| 头条 | 股市 | 港股 | 环球 | 公司 | 券商 | 基金 | 地产 | 金融 | 汽车 | 科创 | 创业版 | 品见 | 期货 | 投教 |
| ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ------ | ---- | ---- | ---- |
| 1000 | 1003 | 1135 | 1007 | 1005 | 1118 | 1110 | 1006 | 1032 | 1119 | 1111 | 1127 | 1160 | 1124 | 1176 |`,
};
async function handler(ctx) {
const category = ctx.req.param('category') ?? '1000';
const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 50;
const title = categories[category];
if (!title) {
throw new InvalidParameterError('Bad category. See <a href="https://docs.rsshub.app/routes/finance#cai-lian-she-shen-du">docs</a>');
}
const apiUrl = `${rootUrl}/v3/depth/home/assembled/${category}`;
const currentUrl = `${rootUrl}/depth?id=${category}`;
const response = await ofetch(apiUrl, {
query: getSearchParams(),
});
let items = [...response.data.top_article, ...response.data.depth_list].slice(0, limit).map((item): DataItem => ({
title: item.title || item.brief,
link: `${rootUrl}/detail/${item.id}`,
pubDate: parseDate(item.ctime, 'X'),
author: item.source,
category: item.article_tag?.map((tag) => tag.name),
image: item.image,
}));
View on GitHub (pinned to bed535e087)
Solutions
- Use one of the documented category codes from the description table (1000, 1003, 1135, 1007, 1005, 1118, 1110, 1006, 1032, 1119, 1111, 1127, 1160, 1124, 1176).
- Omit the param entirely to default to 头条 (1000).
- Maintainers: the message embeds an `<a>` tag — confirm the RSS reader escapes it; consider plain-text guidance.
Example fix
// before /cls/depth/9999 // after /cls/depth/1000
Defensive patterns
Strategy: validation
Validate before calling
const CLS_DEPTH = ['1000','1003','1135','1007','1005','1118','1110','1006','1032','1119','1111','1127','1160','1124','1176'];
if (!(category in categories)) {
throw new Error(`Bad category '${category}'. Use one of: ${CLS_DEPTH.join(', ')}`);
} Type guard
function isClsDepthCategory(c: string): boolean {
return ['1000','1003','1135','1007','1005','1118','1110','1006','1032','1119','1111','1127','1160','1124','1176'].includes(c);
} Prevention
- Use the exact numeric codes from the description table; do not guess from the CLS app.
- Omit the param to default to 1000.
- Maintainers: strip the raw `<a>` HTML from the message — it can render as markup in some readers.
When it happens
Trigger: Calling `/cls/depth/<category>` with a numeric code not in the categories map (e.g. 9999, 1001), or a non-numeric value.
Common situations: User copies a category id from the CLS app that is valid for a different CLS endpoint (e.g. depth vs telegraph) but not for the depth feed.
Related errors
- unknown site: ${site}
- Unsupported region code: ${region}
- Invalid type parameter
- Invalid type parameter
- Invalid category: ${category}
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/f0e6289922f00dd1.
Report an issue: GitHub.