DIYgod/RSSHub · error · InvalidParameterError
invalid type
Error message
invalid type
What it means
Thrown by the USTC math school route when the `type` path parameter is not found in the internal `map` of valid types. The valid types are `xyxw` (学院新闻), `tzgg` (通知公告), `xsjl` (学术交流), and `xsbg` (学术报告). This is an `InvalidParameterError`, which RSSHub maps to an HTTP 400 response, making it a user-facing validation error rather than a server crash.
Source
Thrown at lib/routes/ustc/math.ts:51
{
source: ['math.ustc.edu.cn/'],
target: '/math',
},
],
name: '数学科学学院',
maintainers: ['ne0-wu'],
handler,
url: 'math.ustc.edu.cn/',
description: `| 学院新闻 | 通知公告 | 学术交流 | 学术报告 |
| -------- | -------- | -------- | -------- |
| xyxw | tzgg | xsjl | xsbg |`,
};
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 response = await got(`${host}/${id}/list.htm`);
const $ = load(response.data);
let items = $('#wp_news_w6 > .wp_article_list > .list_item')
.toArray()
.map((item): DataItem => {
const elem = $(item);
const title = elem.find('.Article_Title > a').attr('title');
let link = elem.find('.Article_Title > a').attr('href');
link = link!.startsWith('/') ? host + link : link;
// Assume that the articles are published at 12:00 UTC+8
const pubDate = timezone(parseDate(elem.find('.Article_PublishDate').text(), 'YYYY-MM-DD'), -4);
return {
title: title!,
pubDate,View on GitHub (pinned to bed535e087)
Solutions
- Use one of the four valid type codes: `xyxw`, `tzgg`, `xsjl`, or `xsbg`.
- Omit the type segment to use the default `tzgg`: `/ustc/math`.
- Check the route description table in the route metadata for the current valid codes.
Example fix
// before GET /ustc/math/news // after GET /ustc/math/tzgg
Defensive patterns
Strategy: validation
Validate before calling
const VALID_TYPES = ['xyxw', 'tzgg', 'xsjl', 'xsbg'];
if (!VALID_TYPES.includes(type)) {
throw new InvalidParameterError(`Invalid type: ${type}. Valid types: ${VALID_TYPES.join(', ')}`);
} Type guard
function isValidMathType(type: string): type is 'xyxw' | 'tzgg' | 'xsjl' | 'xsbg' {
return ['xyxw', 'tzgg', 'xsjl', 'xsbg'].includes(type);
} Prevention
- Always check the route's description table for valid type codes before subscribing.
- URL-encode type parameters to avoid silent character corruption.
- The existing Map-based lookup is good practice — extend it by including valid values in the error message.
When it happens
Trigger: A request to `/ustc/math/:type` where `:type` is not one of `xyxw`, `tzgg`, `xsjl`, or `xsbg`. For example `/ustc/math/news` or `/ustc/math/XSZW`. The parameter defaults to `tzgg` when omitted, so only an explicitly wrong value triggers it.
Common situations: Typo in the type parameter, using an English word instead of the pinyin abbreviation, or an outdated bookmark pointing to a type code that was renamed or removed.
Related errors
- invalid type
- No topic named ${topic}
- 该公众号不存在,有关如何获取公众号 id,详见 https://docs.rsshub.app/routes/new-m
- 不支持指定类型!
- 不支持指定类型!
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/46f9e8a67cdea51e.
Report an issue: GitHub.