DIYgod/RSSHub · error · InvalidParameterError

invalid sort parameter, should be `hot`, `created`, or `repl

Error message

invalid sort parameter, should be `hot`, `created`, or `replied`

What it means

The /qq/pd/guild/:id/:sub?/:sort? route validates the `:sort` path segment against a fixed `sortMap` object whose keys are exactly `hot`, `created`, and `replied`. `Object.hasOwn(sortMap, sort)` returns false for any other string (or undefined that was not defaulted), and the handler throws immediately with the documented set of allowed values. The throw happens before the upstream Tencent QQ Channels API is contacted.

Source

Thrown at lib/routes/qq/pd/guild.ts:55

        supportPodcast: false,
        supportScihub: false,
    },
    radar: [
        {
            source: ['pd.qq.com/'],
        },
    ],
    name: '腾讯频道',
    maintainers: ['mobyw'],
    handler,
    url: 'pd.qq.com/',
};

async function handler(ctx: Context): Promise<Data> {
    const { id, sub = 'hot', sort = 'created' } = ctx.req.param();

    if (!Object.hasOwn(sortMap, sort)) {
        throw new InvalidParameterError('invalid sort parameter, should be `hot`, `created`, or `replied`');
    }
    const sortType = sortMap[sort];

    let url: string;
    let body = {};
    let headers = {};

    if (sub === 'hot') {
        url = getGuildFeedsUrl;
        // notice: do not change the order of the keys in the body
        body = { count: 20, from: 7, guild_number: id, get_type: 1, feedAttchInfo: '', sortOption: sortType, need_channel_list: false, need_top_info: false };
        headers = {
            cookie: 'p_uin=o09000002',
            'x-oidb': '{"uint32_service_type":12}',
            'x-qq-client-appid': '537246381',
        };
    } else {
        url = getChannelTimelineFeedsUrl;

View on GitHub (pinned to bed535e087)

Solutions

  1. Use exactly one of: `hot`, `created`, or `replied` as the `:sort` segment.
  2. Omit `:sort` so the destructure default `'created'` applies.
  3. If you need a new sort option, add a key to `sortMap` in lib/routes/qq/pd/guild.ts:17 and map it to the upstream integer.

Example fix

// before
/rsshub/qq/pd/guild/qrp4pkq01d/650967831/latest
// after
/rsshub/qq/pd/guild/qrp4pkq01d/650967831/replied
Defensive patterns

Strategy: type-guard

Validate before calling

const VALID_SORTS = ['hot', 'created', 'replied'] as const;
type Sort = typeof VALID_SORTS[number];
const sort = ctx.req.param('sort') ?? 'created';
if (!VALID_SORTS.includes(sort as Sort)) {
    return ctx.body(`Invalid sort. Use one of: ${VALID_SORTS.join(', ')}`, 400);
}

Type guard

const isSort = (v: unknown): v is 'hot' | 'created' | 'replied' =>
    v === 'hot' || v === 'created' || v === 'replied';

Prevention

When it happens

Trigger: Thrown at lib/routes/qq/pd/guild.ts:55 when the library encounters an invalid state.

Common situations: User guesses a sort name, copies a value from a different RSSHub route (e.g. `mr`, `views`), or passes a localized string like `最新`.

Related errors


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