DIYgod/RSSHub · error · Error
No such sub type.
Error message
No such sub type.
What it means
In handlePostList, for types xyxw/kxyj/tzgg, the sub parameter must be either 'all' or a key of categoryMap[type].sub (e.g. xyyw, hzjl, mtjj, xgyw for xyxw). Anything else reaches the else branch.
Source
Thrown at lib/routes/whu/rsgis.ts:205
async function handlePostList(type: string, sub: string): Promise<DataItem[]> {
let urlList: Array<{ url: string; base: string }> = [];
const category = categoryMap[type];
if (sub === 'all') {
const subMap = category.sub;
urlList = Object.values<{ path: string }>(subMap).map((value) => {
const subtype = value;
return {
url: `${baseUrl}/${category.path}/${subtype.path}.htm`,
base: `${baseUrl}/${category.path}`,
};
});
} else if (Object.hasOwn(category.sub, sub)) {
urlList.push({
url: `${baseUrl}/${category.path}/${category.sub[sub].path}.htm`,
base: `${baseUrl}/${category.path}`,
});
} else {
throw new Error('No such sub type.');
}
const urlPosts = await Promise.all(
urlList.map(async (url) => {
const response = await ofetch(url.url);
const $ = load(response);
return $('div.neiinner > div.nav_right > div.right_inner > div.list > ul > li')
.toArray()
.map((item) => parseListLinkDateItem($(item), url.base));
})
);
const fullList = await Promise.all(urlPosts.flat().map(async (item) => await getDetail(item)));
return fullList;
}
export const route: Route = {
path: '/rsgis/:type/:sub?',
categories: ['university'],
example: '/whu/rsgis/index',View on GitHub (pinned to bed535e087)
Solutions
- Use 'all' or one of the sub keys listed in the route description table for the chosen type.
- Double-check the sub belongs to the same type (subs are type-scoped in categoryMap).
- Omit sub entirely — it defaults to 'all'.
Example fix
// before /whu/rsgis/xyxw/xsbg // xsbg belongs to kxyj, not xyxw // after /whu/rsgis/kxyj/xsbg
Defensive patterns
Strategy: validation
Validate before calling
const category = categoryMap[type];
const validSubs = new Set(['all', ...Object.keys(category.sub)]);
if (!validSubs.has(sub)) {
throw new InvalidParameterError(`sub must be one of: ${[...validSubs].join(', ')} — got ${sub}`);
} Type guard
function isValidSub(type: string, sub: string): boolean {
return sub === 'all' || Object.hasOwn(categoryMap[type]?.sub ?? {}, sub);
} Try / catch
try {
itemList = await handlePostList(type, sub);
} catch (e) {
if (e instanceof Error && e.message === 'No such sub type.') {
throw new InvalidParameterError(`Unknown sub '${sub}' for type '${type}'`);
}
throw e;
} Prevention
- Validate sub against the type-scoped categoryMap before fetching.
- Surface valid options in the error message so callers self-correct.
- Default sub to 'all' at the handler boundary so undefined never reaches the check.
When it happens
Trigger: Requesting /whu/rsgis/xyxw/<invalid> where <invalid> is not 'all' and not present in categoryMap[xyxw].sub — e.g. /whu/rsgis/xyxw/foo or a sub key that belongs to a different type.
Common situations: Cross-type sub confusion (using a kxyj sub like xsbg under xyxw), typo, or stale docs.
Related errors
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/597a3efd78dc0c7c.
Report an issue: GitHub.