DIYgod/RSSHub · error

Unknown order: ${order}

Error message

Unknown order: ${order}

What it means

Generic Error thrown by the live-search route when the :order path parameter does not match 'live_time' or 'online'. Identical validation pattern to live-area but for the live search route. The switch default fires before the wbi-signed search API call is made.

Source

Thrown at lib/routes/bilibili/live-search.ts:40

    handler,
};

async function handler(ctx) {
    const key = ctx.req.param('key');
    const order = ctx.req.param('order');

    const urlEncodedKey = encodeURIComponent(key);
    let orderTitle: string;

    switch (order) {
        case 'live_time':
            orderTitle = '最新开播';
            break;
        case 'online':
            orderTitle = '人气直播';
            break;
        default:
            throw new Error(`Unknown order: ${order}`);
    }
    const wbiVerifyString = await cache.getWbiVerifyString();
    let params = `__refresh__=true&_extra=&context=&page=1&page_size=42&order=${order}&duration=&from_source=&from_spmid=333.337&platform=pc&highlight=1&single_column=0&keyword=${urlEncodedKey}&ad_resource=&source_tag=3&gaia_vtoken=&category_id=&search_type=live&dynamic_offset=0&web_location=1430654`;
    params = utils.addWbiVerifyInfo(params, wbiVerifyString);

    const response = await got({
        method: 'get',
        url: `https://api.bilibili.com/x/web-interface/wbi/search/type?${params}`,
        headers: {
            Referer: `https://search.bilibili.com/live?keyword=${urlEncodedKey}&from_source=webtop_search&spm_id_from=444.7&search_source=3&search_type=live_room`,
            Cookie: await cache.getCookie(),
        },
    });
    const data = response.data.data.result.live_room;

    return {
        title: `哔哩哔哩直播-${key}-${orderTitle}`,
        link: `https://search.bilibili.com/live?keyword=${urlEncodedKey}&order=${order}&coverType=user_cover&page=1&search_type=live`,

View on GitHub (pinned to bed535e087)

Solutions

  1. Use 'live_time' or 'online' as the order parameter.
  2. Correct the subscription URL in your RSS reader.

Example fix

// before
// /bilibili/live/search/game/popular

// after
// /bilibili/live/search/game/online
Defensive patterns

Strategy: validation

Validate before calling

const validOrders = ['live_time', 'online'] as const;
if (!validOrders.includes(order as any)) {
    throw new Error(`Invalid order '${order}'. Use 'live_time' or 'online'.`);
}

Type guard

function isValidOrder(order: string): order is 'live_time' | 'online' {
    return order === 'live_time' || order === 'online';
}

Prevention

When it happens

Trigger: Requesting /bilibili/live/search/:key/:order with an order value other than 'live_time' or 'online'.

Common situations: Incorrect order value in the subscription URL; user assumed different sort options exist; typo.

Related errors


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