{"record":{"id":"f0e6289922f00dd1","repo":"DIYgod/RSSHub","slug":"bad-category-see-a-href-https-docs-rsshub-app-f0e628","errorCode":null,"errorMessage":"Bad category. See <a href=\"https://docs.rsshub.app/routes/finance#cai-lian-she-shen-du\">docs</a>","messagePattern":"Bad category\\. See <a href=\"https://docs\\.rsshub\\.app/routes/finance#cai-lian-she-shen-du\">docs</a>","errorType":"exception","errorClass":"InvalidParameterError","httpStatus":null,"severity":"warning","filePath":"lib/routes/cls/depth.ts","lineNumber":58,"sourceCode":"        supportPodcast: false,\n        supportScihub: false,\n    },\n    name: '深度',\n    maintainers: ['nczitzk'],\n    handler,\n    description: `| 头条 | 股市 | 港股 | 环球 | 公司 | 券商 | 基金 | 地产 | 金融 | 汽车 | 科创 | 创业版 | 品见 | 期货 | 投教 |\n| ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ------ | ---- | ---- | ---- |\n| 1000 | 1003 | 1135 | 1007 | 1005 | 1118 | 1110 | 1006 | 1032 | 1119 | 1111 | 1127   | 1160 | 1124 | 1176 |`,\n};\n\nasync function handler(ctx) {\n    const category = ctx.req.param('category') ?? '1000';\n    const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 50;\n\n    const title = categories[category];\n\n    if (!title) {\n        throw new InvalidParameterError('Bad category. See <a href=\"https://docs.rsshub.app/routes/finance#cai-lian-she-shen-du\">docs</a>');\n    }\n\n    const apiUrl = `${rootUrl}/v3/depth/home/assembled/${category}`;\n    const currentUrl = `${rootUrl}/depth?id=${category}`;\n\n    const response = await ofetch(apiUrl, {\n        query: getSearchParams(),\n    });\n\n    let items = [...response.data.top_article, ...response.data.depth_list].slice(0, limit).map((item): DataItem => ({\n        title: item.title || item.brief,\n        link: `${rootUrl}/detail/${item.id}`,\n        pubDate: parseDate(item.ctime, 'X'),\n        author: item.source,\n        category: item.article_tag?.map((tag) => tag.name),\n        image: item.image,\n    }));\n","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/cls/depth.ts#L40-L76","documentation":"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=...>`).","triggerScenarios":"Calling `/cls/depth/<category>` with a numeric code not in the categories map (e.g. 9999, 1001), or a non-numeric value.","commonSituations":"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.","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."],"exampleFix":"// before\n/cls/depth/9999\n// after\n/cls/depth/1000","handlingStrategy":"validation","validationCode":"const CLS_DEPTH = ['1000','1003','1135','1007','1005','1118','1110','1006','1032','1119','1111','1127','1160','1124','1176'];\nif (!(category in categories)) {\n    throw new Error(`Bad category '${category}'. Use one of: ${CLS_DEPTH.join(', ')}`);\n}","typeGuard":"function isClsDepthCategory(c: string): boolean {\n    return ['1000','1003','1135','1007','1005','1118','1110','1006','1032','1119','1111','1127','1160','1124','1176'].includes(c);\n}","tryCatchPattern":null,"preventionTips":["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."],"tags":["validation","user-input","invalid-parameter-error","lookup-table"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}