DIYgod/RSSHub · warning · Error
Unknown channel type: ${type}. Valid values: ${Object.keys(C
Error message
Unknown channel type: ${type}. Valid values: ${Object.keys(CATEGORIES).join(', ')} What it means
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.
Source
Thrown at lib/routes/in-en/index.ts:52
},
name: '新闻',
maintainers: ['Harviewang'],
description: `| 频道 | type 参数 |
| ---------- | --------- |
| 光伏太阳能 | solar |
| 风电 | wind |
| 储能 | chuneng |
| 氢能 | h2 |
| 充换电 | chd |
| 新能源综合 | newenergy |
| 电力 | power |
| 环保 | huanbao |`,
async handler(ctx) {
const type = ctx.req.param('type')!;
const cat = CATEGORIES[type];
if (!cat) {
throw new Error(`Unknown channel type: ${type}. Valid values: ${Object.keys(CATEGORIES).join(', ')}`);
}
const baseUrl = `https://${type}.in-en.com`;
const listUrl = `${baseUrl}${cat.newsPath}`;
const html = await ofetch(listUrl);
const $ = load(html);
// Each `ul.infoList > li` carries a single `.prompt` block with this fixed shape:
// <i>{relative or absolute date}</i>
// <span>来源:{author or <em class="ly">{author}</em>}</span>
// <span><em>{<a>{category}</a>}+</em></span>
// See https://solar.in-en.com/news/ for live samples.
const list: DataItem[] = $('ul.infoList > li')
.toArray()
.map((el) => {
const $el = $(el);
const $a = $el.find('.listTxt h5 a');View on GitHub (pinned to bed535e087)
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.
Example fix
// before (broken) // GET /in-en/news/nuclear // after (correct) // GET /in-en/news/power
Defensive patterns
Strategy: validation
Validate before calling
const VALID_TYPES = Object.keys(CATEGORIES); // ['solar', 'wind', 'chuneng', 'h2', 'chd', 'newenergy', 'power', 'huanbao']
function isValidType(type: string): boolean {
return VALID_TYPES.includes(type);
} Type guard
function isKnownInEnType(type: string): type is keyof typeof CATEGORIES {
return type in CATEGORIES;
} Prevention
- Use `InvalidParameterError` for HTTP 400 consistency.
- Keep the CATEGORIES record and description table in sync.
- Consider using `parameters.options` to auto-document valid types.
When it happens
Trigger: 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`).
Common situations: 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`).
Related errors
- Bad category. See <a href="https://docs.rsshub.app/routes/ne
- Bad category. See <a href="https://docs.rsshub.app/routes/ne
- Bad category. See <a href="https://docs.rsshub.app/routes/ne
- Unknown channel
- Bad category. See <a href="https://docs.rsshub.app/routes/go
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/0c928e609246358a.
Report an issue: GitHub.