{"record":{"id":"0c928e609246358a","repo":"DIYgod/RSSHub","slug":"unknown-channel-type-type-valid-values-obj","errorCode":null,"errorMessage":"Unknown channel type: ${type}. Valid values: ${Object.keys(CATEGORIES).join(', ')}","messagePattern":"Unknown channel type: (.+?)\\. Valid values: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"lib/routes/in-en/index.ts","lineNumber":52,"sourceCode":"    },\n    name: '新闻',\n    maintainers: ['Harviewang'],\n    description: `| 频道       | type 参数 |\n| ---------- | --------- |\n| 光伏太阳能 | solar     |\n| 风电       | wind      |\n| 储能       | chuneng   |\n| 氢能       | h2        |\n| 充换电     | chd       |\n| 新能源综合 | newenergy |\n| 电力       | power     |\n| 环保       | huanbao   |`,\n\n    async handler(ctx) {\n        const type = ctx.req.param('type')!;\n        const cat = CATEGORIES[type];\n        if (!cat) {\n            throw new Error(`Unknown channel type: ${type}. Valid values: ${Object.keys(CATEGORIES).join(', ')}`);\n        }\n\n        const baseUrl = `https://${type}.in-en.com`;\n        const listUrl = `${baseUrl}${cat.newsPath}`;\n\n        const html = await ofetch(listUrl);\n        const $ = load(html);\n\n        // Each `ul.infoList > li` carries a single `.prompt` block with this fixed shape:\n        //   <i>{relative or absolute date}</i>\n        //   <span>来源：{author or <em class=\"ly\">{author}</em>}</span>\n        //   <span><em>{<a>{category}</a>}+</em></span>\n        // See https://solar.in-en.com/news/ for live samples.\n        const list: DataItem[] = $('ul.infoList > li')\n            .toArray()\n            .map((el) => {\n                const $el = $(el);\n                const $a = $el.find('.listTxt h5 a');","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/in-en/index.ts#L34-L70","documentation":"Thrown by the in-en.com (国际能源网) news route when the `:type` path parameter does not match any key in the `CATEGORIES` record. The categories map energy channel slugs to their display names and news list paths. The handler does a simple `CATEGORIES[type]` lookup and throws a plain `Error` (not `InvalidParameterError`) listing all valid keys.","triggerScenarios":"Requesting `/in-en/news/<type>` where `<type>` is not one of: `solar`, `wind`, `chuneng`, `h2`, `chd`, `newenergy`, `power`, `huanbao`. The type is used directly as a subdomain (`https://${type}.in-en.com`).","commonSituations":"Typo in the channel type, using an energy category not covered (e.g. `nuclear`, `coal`), or using a display name instead of the slug (e.g. `光伏` instead of `solar`).","solutions":["Use one of the documented types: `solar`, `wind`, `chuneng`, `h2`, `chd`, `newenergy`, `power`, `huanbao`.","As a maintainer: switch to `InvalidParameterError` for HTTP 400 semantics."],"exampleFix":"// before (broken)\n// GET /in-en/news/nuclear\n\n// after (correct)\n// GET /in-en/news/power","handlingStrategy":"validation","validationCode":"const VALID_TYPES = Object.keys(CATEGORIES); // ['solar', 'wind', 'chuneng', 'h2', 'chd', 'newenergy', 'power', 'huanbao']\nfunction isValidType(type: string): boolean {\n    return VALID_TYPES.includes(type);\n}","typeGuard":"function isKnownInEnType(type: string): type is keyof typeof CATEGORIES {\n    return type in CATEGORIES;\n}","tryCatchPattern":null,"preventionTips":["Use `InvalidParameterError` for HTTP 400 consistency.","Keep the CATEGORIES record and description table in sync.","Consider using `parameters.options` to auto-document valid types."],"tags":["parameter-validation","rsshub","new-media"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}