DIYgod/RSSHub · error · Error

Invalid type or subtype

Error message

Invalid type or subtype

What it means

Thrown by the GMU (Guangzhou Medical University) graduate school route when either the ':type' or ':subtype' path parameter does not match the nested 'sections' object structure. The sections object has five top-level keys (zsgz, pygz, xwgz, xsgz, xzzx), each containing valid subtype keys (e.g., tzgg, xwsd, gzzd). The check uses Object.hasOwn for both levels.

Solutions

  1. Refer to the sections object in the source for the exact type/subtype matrix — only specific combinations are valid
  2. Use the documented example: /gmu/yjs/zsgz/tzgg
  3. Check the route parameters options declaration which lists all valid type and subtype values

Example fix

// before
if (!Object.hasOwn(sections, type) || !Object.hasOwn(sections[type], subtype)) {
    throw new Error('Invalid type or subtype');
}

// after (use InvalidParameterError with guidance)
import InvalidParameterError from '@/errors/types/invalid-parameter';
// ...
if (!Object.hasOwn(sections, type) || !Object.hasOwn(sections[type], subtype)) {
    throw new InvalidParameterError(`Invalid type '${type}' or subtype '${subtype}'. See route documentation for valid combinations.`);
}
Defensive patterns

Strategy: type-guard

Type guard

function isValidSection(type: string, subtype: string): boolean {
    return Object.hasOwn(sections, type) && Object.hasOwn(sections[type], subtype);
}

// Usage in handler:
const { type, subtype } = ctx.req.param();
if (!isValidSection(type, subtype)) {
    throw new InvalidParameterError(`Invalid type/subtype combination: ${type}/${subtype}`);
}

Prevention

When it happens

Trigger: A request to /gmu/yjs/:type/:subtype where type is not a key in sections, or where type exists but subtype is not a key within sections[type]. For example, /gmu/yjs/zsgz/pyxz fails because 'pyxz' is not a valid subtype under 'zsgz' (it belongs to 'xzzx'). Not every subtype is valid for every type.

Common situations: Mixing a valid type with a subtype from a different section (e.g., zsgz/pyxz); typos in path segments; guessing subtypes that don't exist for a given type.

Related errors


AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12). Data as JSON: /api/errors/d0a2cb55935d65b9. Report an issue: GitHub.

Appendix: source

Thrown at lib/routes/gmu/yjs.ts:93

        supportPodcast: false,
        supportScihub: false,
    },
    name: '研究生院',
    maintainers: ['FrankFahey'],
    radar: [
        {
            source: ['yjs.gmu.cn/:type/:subtype.htm', 'yjs.gmu.cn/'],
            target: '/yjs/:type/:subtype',
        },
    ],
    handler,
};

export async function handler(ctx: Context) {
    const { type, subtype } = ctx.req.param();

    if (!Object.hasOwn(sections, type) || !Object.hasOwn(sections[type], subtype)) {
        throw new Error('Invalid type or subtype');
    }

    const { title, path } = sections[type][subtype];
    const baseUrl = 'https://yjs.gmu.cn';
    const link = baseUrl + path;

    const response = await got(link);

    const $ = load(response.data);

    // 更新选择器以匹配研究生院网站的实际结构
    const list = $('.n_listxx1 li');

    if (list.length === 0) {
        throw new Error('No content found. The page structure might have changed.');
    }

    const items = await Promise.all(

View on GitHub (pinned to bed535e087)