DIYgod/RSSHub · warning · Error
Invalid type parameter
Error message
Invalid type parameter
What it means
Thrown by the BUCT (Beijing University of Chemical Technology) 'gr' route when the `type` path parameter does not match either 'jzml' or 'xgzc'. The handler uses a switch statement and falls through to a `default` case that raises a plain `Error('Invalid type parameter')` instead of RSSHub's `InvalidParameterError`, so downstream it surfaces as a generic 500 rather than a clean 400. It is purely an input-validation guard: the value is never sent to the remote server.
Source
Thrown at lib/routes/buct/gr.ts:63
switch (type) {
case 'tzgg':
currentUrl = `${rootUrl}/1392/list.htm`;
break;
case 'jzml':
currentUrl = `${rootUrl}/jzml/list.htm`;
break;
case 'xgzc':
currentUrl = `${rootUrl}/1393/list.htm`;
break;
default:
throw new Error('Invalid type parameter');
}
const response = await got.get(currentUrl);
const $ = load(response.data);
const list = $('ul.wp_article_list > li.list_item')
.toArray()
.map((item): DataItem => ({
pubDate: $(item).find('.Article_PublishDate').text(),
title: $(item).find('a').attr('title')!,
link: `${rootUrl}${$(item).find('a').attr('href')}`,
}));
const items = await Promise.all(
list.map((item) =>
cache.tryGet(item.link!, async () => {
const detailResponse = await got.get(item.link);
const content = load(detailResponse.data);View on GitHub (pinned to bed535e087)
Solutions
- Use only the two documented values: `/buct/gr/jzml` or `/buct/gr/xgzc`.
- If you maintain this route, replace `throw new Error(...)` with `throw new InvalidParameterError('Invalid type parameter')` and enumerate allowed values in the route `description` table.
- Verify the param against the switch's case labels (jzml, xgzc) before constructing the request.
Example fix
// before
throw new Error('Invalid type parameter');
// after
import InvalidParameterError from '@/errors/types/invalid-parameter';
throw new InvalidParameterError('Invalid type parameter. Supported: jzml, xgzc'); Defensive patterns
Strategy: validation
Validate before calling
const BUCT_GR_TYPES = ['jzml', 'xgzc'] as const;
function validateBuctType(type: string): void {
if (!BUCT_GR_TYPES.includes(type as any)) {
throw new Error(`Invalid type '${type}'. Use one of: ${BUCT_GR_TYPES.join(', ')}`);
}
} Type guard
const BUCT_GR_TYPES = ['jzml', 'xgzc'] as const;
type BuctGrType = typeof BUCT_GR_TYPES[number];
function isBuctGrType(v: string): v is BuctGrType {
return (BUCT_GR_TYPES as readonly string[]).includes(v);
} Prevention
- Document the allowed type values in the route description table so callers see them at /buct.
- Prefer `InvalidParameterError` over plain `Error` for input-validation failures so RSSHub returns a 400.
- If you consume this feed programmatically, validate the path segment against the constant list before issuing the request.
When it happens
Trigger: Requesting `/buct/gr/<anything-other-than-jzml-or-xgzc>`, e.g. `/buct/gr/tzgg`, `/buct/gr/news`, `/buct/gr/` (empty). Any path segment that the switch does not explicitly case.
Common situations: Copying a type value from a different BUCT route (e.g. the `bupt/jwc` route uses tzgg/xwzx), outdated third-party docs listing removed categories, URL-encoding artifacts, or a trailing slash producing an empty param.
Related errors
- Invalid type parameter
- Invalid category: ${category}
- Unsupported region code: ${region}
- Unsupported key
- Unknown type: ${type}
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/f8276ecb01f5a3e7.
Report an issue: GitHub.