{"record":{"id":"b3cb25c19bb3ed01","repo":"DIYgod/RSSHub","slug":"bad-type-see-a-href-https-docs-rsshub-app-rou","errorCode":null,"errorMessage":"Bad type. See <a href=\"https://docs.rsshub.app/routes/new-media#it-zhi-jia\">https://docs.rsshub.app/routes/new-media#it-zhi-jia</a>","messagePattern":"Bad type\\. See <a href=\"https://docs\\.rsshub\\.app/routes/new-media#it-zhi-jia\">https://docs\\.rsshub\\.app/routes/new-media#it-zhi-jia</a>","errorType":"validation","errorClass":"InvalidParameterError","httpStatus":null,"severity":"error","filePath":"lib/routes/ithome/ranking.ts","lineNumber":54,"sourceCode":"    const $ = load(response.data);\n\n    const config = {\n        '24h': '24 小时最热',\n        '7days': '7 天最热',\n        monthly: '月榜',\n    };\n\n    const type2id = {\n        '24h': 'd-1',\n        '7days': 'd-2',\n        monthly: 'd-3',\n    };\n\n    const title = config[option];\n    const id = type2id[option];\n\n    if (!id) {\n        throw new InvalidParameterError('Bad type. See <a href=\"https://docs.rsshub.app/routes/new-media#it-zhi-jia\">https://docs.rsshub.app/routes/new-media#it-zhi-jia</a>');\n    }\n\n    const list = $(`#${id} > li`)\n        .toArray()\n        .map((item) => {\n            const info: DataItem = {\n                title: $(item).find('a').text(),\n                link: $(item).find('a').attr('href'),\n            };\n            return info;\n        });\n\n    const items = await Promise.all(\n        list.map((item) =>\n            cache.tryGet(item.link!, async () => {\n                const res = await got({\n                    method: 'get',\n                    url: item.link,","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/ithome/ranking.ts#L36-L72","documentation":"Thrown by the ithome ranking route as `InvalidParameterError('Bad type')` when the `type` path param is not a key in the `type2id` map. Valid types are `24h`, `7days`, `monthly` (mapped to ranking-section ids `d-1`, `d-2`, `d-3`).","triggerScenarios":"Request to `/ithome/ranking/:type` where `type` is anything other than `24h`, `7days`, or `monthly` — e.g. `/ithome/ranking/daily`, `/ithome/ranking/year`, or a typo. The check `if (!id)` fires because `type2id[option]` is undefined.","commonSituations":"User passes a plausible-but-wrong period name (`daily`, `weekly`, `year`); typo; outdated docs.","solutions":["Use one of the valid keys: `/ithome/ranking/24h`, `/ithome/ranking/7days`, `/ithome/ranking/monthly`.","If a new ranking period is added to ithome's rank page, add the mapping to `type2id` and `config` in lib/routes/ithome/ranking.ts."],"exampleFix":"// before: /ithome/ranking/daily\n// after:  /ithome/ranking/24h","handlingStrategy":"validation","validationCode":"const id = type2id[option];\nif (!id) throw new InvalidParameterError(`Bad type. Valid: ${Object.keys(type2id).join(', ')}`);","typeGuard":"const isKnownRankingType = (t: string): t is keyof typeof type2id => t in type2id;","tryCatchPattern":null,"preventionTips":["Use only 24h / 7days / monthly.","Surface valid keys in the error.","Share the type2id map with the route description."],"tags":["ithome","invalid-parameter","ranking"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}