DIYgod/RSSHub · warning · InvalidParameterError
invalid type
Error message
invalid type
What it means
InvalidParameterError from the NJUST 电光学院 (EOE) route. Same Map-lookup pattern. Valid type keys are tzgg / xwdt.
Source
Thrown at lib/routes/njust/eoe.ts:42
requirePuppeteer: true,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
name: '电光学院',
maintainers: ['jasongzy'],
handler,
description: `| 通知公告 | 新闻动态 |
| -------- | -------- |
| tzgg | xwdt |`,
};
async function handler(ctx) {
const type = ctx.req.param('type') ?? 'tzgg';
const info = map.get(type);
if (!info) {
throw new InvalidParameterError('invalid type');
}
const id = info.id;
const siteUrl = host + id + '/list.htm';
const html = await getContent(siteUrl, true);
const $ = load(html);
const list = $('ul.news_ul').find('li');
return {
title: info.title,
link: siteUrl,
item: list.toArray().map((item) => ({
title: $(item).find('a').attr('title')!.trim(),
pubDate: timezone(parseDate($(item).find('span').text(), 'YYYY-MM-DD'), 8),
link: $(item).find('a').attr('href'),
})),
};
}View on GitHub (pinned to bed535e087)
Solutions
- Use tzgg (通知公告) or xwdt (新闻动态) for this route.
- Verify against the route description table.
- Each njust/* route defines its own valid codes.
Example fix
// before
const info = map.get(type);
if (!info) {
throw new InvalidParameterError('invalid type');
}
// after — caller: GET /njust/eoe/tzgg or /njust/eoe/xwdt Defensive patterns
Strategy: validation
Validate before calling
const VALID = new Set(['tzgg','xwdt']);
function buildNjustEoeUrl(type) {
if (!VALID.has(type)) throw new Error(`invalid type '${type}'. Valid: ${[...VALID].join(', ')}`);
return host + MAP[type] + '/list.htm';
} Type guard
const isEoeType = (t: string): t is 'tzgg'|'xwdt' => VALID.has(t);
Prevention
- Only tzgg / xwdt are valid for EOE.
- Do not copy codes from CS/CWC routes.
- Validate client-side before requesting.
When it happens
Trigger: Calling /njust/eoe/:type with a value not in the EOE map — typo or code from a sibling route.
Common situations: User assumes 'xyxw' (valid on CS) works here — it does not; typo; cross-route code confusion.
Related errors
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/5a12bc16f045fa01.
Report an issue: GitHub.