DIYgod/RSSHub · warning · InvalidParameterError

invalid type

Error message

invalid type

What it means

InvalidParameterError from the NJUST 电光学院研学网 (DGXG) route. Same Map-lookup pattern. Valid type keys are gstz / xswh / jyzd.

Source

Thrown at lib/routes/njust/dgxg.ts:43

        requirePuppeteer: true,
        antiCrawler: false,
        supportBT: false,
        supportPodcast: false,
        supportScihub: false,
    },
    name: '电光学院研学网',
    maintainers: ['jasongzy'],
    handler,
    description: `| 公示通知 | 学术文化 | 就业指导 |
| -------- | -------- | -------- |
| gstz     | xswh     | jyzd     |`,
};

async function handler(ctx) {
    const type = ctx.req.param('type') ?? 'gstz';
    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.wp_article_list').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.Article_PublishDate').text(), 'YYYY-MM-DD'), 8),
            link: $(item).find('a').attr('href'),
        })),
    };
}

View on GitHub (pinned to bed535e087)

Solutions

  1. Use one of gstz (公示通知), xswh (学术文化), jyzd (就业指导).
  2. Cross-check against the route description table.
  3. Treat each njust/* route as having an independent code set.

Example fix

// before
const info = map.get(type);
if (!info) {
    throw new InvalidParameterError('invalid type');
}

// after — caller: GET /njust/dgxg/gstz | xswh | jyzd
Defensive patterns

Strategy: validation

Validate before calling

const VALID = new Set(['gstz','xswh','jyzd']);
function buildNjustDgxgUrl(type) {
  if (!VALID.has(type)) throw new Error(`invalid type '${type}'. Valid: ${[...VALID].join(', ')}`);
  return host + MAP[type] + '/list.htm';
}

Type guard

const isDgxgType = (t: string): t is 'gstz'|'xswh'|'jyzd' => VALID.has(t);

Prevention

When it happens

Trigger: Calling /njust/dgxg/:type with a value outside the route's map — typo or a code from a sibling route.

Common situations: User copies a code from njust/eoe or njust/cs that is not valid here; typo; docs drift.

Related errors


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