DIYgod/RSSHub · warning · Error

Unknown category: ${category}

Error message

Unknown category: ${category}

What it means

Generic Error('Unknown category: <category>') thrown by the USTC 就业信息网 (job) route inside the method IIFE when the category switch falls through to default. Supported categories: RecruitList, Doublechoice, Broadcast, joblist2; default 'joblist2'. The throw happens during construction of the got() options, before any HTTP request.

Source

Thrown at lib/routes/ustc/job.ts:60

    const category = ctx.req.param('category') ?? 'joblist2';

    const rand = 0.01234567890123456;
    const apiRootUrl = 'http://ustc.ahbys.com';
    const rootUrl = 'http://www.job.ustc.edu.cn';

    const currentUrl = `${rootUrl}/${category}.html`;

    const response = await got({
        method: (() => {
            switch (category) {
                case 'RecruitList':
                case 'Broadcast':
                case 'joblist2':
                    return 'get';
                case 'Doublechoice':
                    return 'post';
                default:
                    throw new Error(`Unknown category: ${category}`);
            }
        })(),

        url: (() => {
            switch (category) {
                case 'RecruitList':
                    return `${apiRootUrl}/API/Web/index10358.ashx?rd=${rand}&pagesize=20&pageindex=1&action=bookinglist&kind=13&keyword=`;
                case 'Doublechoice':
                    return `${apiRootUrl}/API/Web/index10358.ashx?rd=${rand}`;
                case 'Broadcast':
                    return `${apiRootUrl}/API/Web/index10358.ashx?rd=${rand}&pagesize=20&pageindex=1&action=bookinglist2&kind=2`;
                case 'joblist2':
                    return `${apiRootUrl}/API/Web/index10358.ashx?action=joblist2&pagesize=50&pageindex=1&rand=${rand}&keyword=`;
                default:
                    throw new Error(`Unknown category: ${category}`);
            }
        })(),

View on GitHub (pinned to bed535e087)

Solutions

  1. Use exactly one of: RecruitList, Doublechoice, Broadcast, joblist2 (case-sensitive).
  2. Omit :category to default to 'joblist2'.
  3. Update saved feed URLs to the current keys.

Example fix

// before
// /ustc/job/recruitlist
// after
// /ustc/job/RecruitList
Defensive patterns

Strategy: type-guard

Validate before calling

const JOB_CATEGORIES = new Set(['RecruitList', 'Doublechoice', 'Broadcast', 'joblist2']);
function isValidJobCategory(c: string | undefined): boolean {
  return c === undefined || JOB_CATEGORIES.has(c);
}

Type guard

type JobCategory = 'RecruitList' | 'Doublechoice' | 'Broadcast' | 'joblist2';
function isJobCategory(c: string): c is JobCategory { return JOB_CATEGORIES.has(c); }

Prevention

When it happens

Trigger: Requesting /ustc/job/<category> with a value outside the four supported categories. The same default branch is replicated in the url IIFE (598) and the form IIFE (599); whichever IIFE evaluates first surfaces, but the cause is identical.

Common situations: Category slug typo; mixed-case (e.g. 'recruitlist' vs 'RecruitList'); outdated feed URL; user guessed from the Chinese label instead of the English key.

Related errors


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