DIYgod/RSSHub · warning · InvalidParameterError

invalid type

Error message

invalid type

What it means

InvalidParameterError from the NJUST 教务处 (JWC) route. Same Map-lookup pattern, default type is 'xstz'. Valid keys are jstz / xstz / xw / xydt.

Source

Thrown at lib/routes/njust/jwc.ts:44

        requirePuppeteer: true,
        antiCrawler: false,
        supportBT: false,
        supportPodcast: false,
        supportScihub: false,
    },
    name: '教务处',
    maintainers: ['MilkShakeYoung', 'jasongzy'],
    handler,
    description: `| 教师通知 | 学生通知 | 新闻 | 学院动态 |
| -------- | -------- | ---- | -------- |
| jstz     | xstz     | xw   | xydt     |`,
};

async function handler(ctx) {
    const type = ctx.req.param('type') ?? 'xstz';
    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 = $('div#wp_news_w3').find('tr');

    return {
        title: info.title,
        link: siteUrl,
        item: list.toArray().map((item) => ({
            title: $(item).find('a').attr('title')!.trim(),
            pubDate: timezone(parseDate($(item).find('td[width="14%"]').text(), 'YYYY-MM-DD'), 8),
            link: $(item).find('a').attr('href'),
        })),
    };
}

View on GitHub (pinned to bed535e087)

Solutions

  1. Use one of jstz (教师通知), xstz (学生通知), xw (新闻), xydt (学院动态).
  2. Refer to the route description table for the authoritative set.
  3. Do not reuse codes from other njust/* routes without checking.

Example fix

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

// after — caller: GET /njust/jwc/jstz | xstz | xw | xydt
Defensive patterns

Strategy: validation

Validate before calling

const VALID = new Set(['jstz','xstz','xw','xydt']);
function buildNjustJwcUrl(type) {
  if (!VALID.has(type)) throw new Error(`invalid type '${type}'. Valid: ${[...VALID].join(', ')}`);
  return host + MAP[type] + '/list.htm';
}

Type guard

const isJwcType = (t: string): t is 'jstz'|'xstz'|'xw'|'xydt' => VALID.has(t);

Prevention

When it happens

Trigger: Calling /njust/jwc/:type with a value not in the JWC map — typo, or a code from another NJUST route (e.g. 'tzgg' which is valid on cwc/eoe but not here).

Common situations: Cross-route code confusion (tzgg vs tzgg-style names differ); typo; outdated docs.

Related errors


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