DIYgod/RSSHub · warning · InvalidParameterError

type not supported

Error message

type not supported

What it means

InvalidParameterError thrown by the UESTC 新闻中心 (news) route when ctx.req.param('type') does not resolve to a key in the map object (academy, culture, announcement, notification). Truthiness of map[type] is checked, so an undefined key triggers the error; default is 'announcement'.

Source

Thrown at lib/routes/uestc/news.ts:50

        {
            source: ['news.uestc.edu.cn/'],
            target: '/news',
        },
    ],
    name: '新闻中心',
    maintainers: ['achjqz', 'mobyw'],
    handler,
    url: 'news.uestc.edu.cn/',
    description: `| 学术    | 文化    | 公告         | 校内通知     |
| ------- | ------- | ------------ | ------------ |
| academy | culture | announcement | notification |`,
};

async function handler(ctx) {
    const type = ctx.req.param('type') || 'announcement';
    const pageUrl = map[type];
    if (!pageUrl) {
        throw new InvalidParameterError('type not supported');
    }

    const response = await got.get(baseUrl + pageUrl);

    const $ = load(response.data);

    const items = $('div.notice-item.clearfix');

    const out = $(items)
        .toArray()
        .map((item) => {
            const $item = $(item);
            const newsTitle = $item.find('a').text().trim();
            const newsLink = baseUrl + $item.find('a').attr('href');
            const newsDate = parseDate($item.find('div.date-box-sm').text().replace(dateRegex, '$1-$2-$3'));
            const newsDescription = $item.find('div.content').text().trim().replace(' ', '');

            return {

View on GitHub (pinned to bed535e087)

Solutions

  1. Use one of: academy, culture, announcement, notification.
  2. Omit :type to default to 'announcement'.
  3. Refresh saved feed URLs against the current route docs.

Example fix

// before
// /uestc/news/academic
// after
// /uestc/news/academy
Defensive patterns

Strategy: type-guard

Validate before calling

const NEWS_TYPES = new Set(['academy', 'culture', 'announcement', 'notification']);
function isValidNewsType(t: string | undefined): boolean {
  return t === undefined || NEWS_TYPES.has(t);
}

Type guard

type NewsType = 'academy' | 'culture' | 'announcement' | 'notification';
function isNewsType(t: string): t is NewsType { return NEWS_TYPES.has(t); }

Prevention

When it happens

Trigger: Requesting /uestc/news/<type> with a slug other than the four supported values.

Common situations: Slug typo; outdated feed URL referencing a retired slug; user misread the two-column description table.

Related errors


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