{"record":{"id":"fe72dbbf52dc6614","repo":"DIYgod/RSSHub","slug":"invalid-sort-parameter-should-be-hot-created","errorCode":null,"errorMessage":"invalid sort parameter, should be `hot`, `created`, or `replied`","messagePattern":"invalid sort parameter, should be `hot`, `created`, or `replied`","errorType":"validation","errorClass":"InvalidParameterError","httpStatus":503,"severity":"error","filePath":"lib/routes/qq/pd/guild.ts","lineNumber":55,"sourceCode":"        supportPodcast: false,\n        supportScihub: false,\n    },\n    radar: [\n        {\n            source: ['pd.qq.com/'],\n        },\n    ],\n    name: '腾讯频道',\n    maintainers: ['mobyw'],\n    handler,\n    url: 'pd.qq.com/',\n};\n\nasync function handler(ctx: Context): Promise<Data> {\n    const { id, sub = 'hot', sort = 'created' } = ctx.req.param();\n\n    if (!Object.hasOwn(sortMap, sort)) {\n        throw new InvalidParameterError('invalid sort parameter, should be `hot`, `created`, or `replied`');\n    }\n    const sortType = sortMap[sort];\n\n    let url: string;\n    let body = {};\n    let headers = {};\n\n    if (sub === 'hot') {\n        url = getGuildFeedsUrl;\n        // notice: do not change the order of the keys in the body\n        body = { count: 20, from: 7, guild_number: id, get_type: 1, feedAttchInfo: '', sortOption: sortType, need_channel_list: false, need_top_info: false };\n        headers = {\n            cookie: 'p_uin=o09000002',\n            'x-oidb': '{\"uint32_service_type\":12}',\n            'x-qq-client-appid': '537246381',\n        };\n    } else {\n        url = getChannelTimelineFeedsUrl;","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/qq/pd/guild.ts#L37-L73","documentation":"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.","triggerScenarios":"Thrown at lib/routes/qq/pd/guild.ts:55 when the library encounters an invalid state.","commonSituations":"User guesses a sort name, copies a value from a different RSSHub route (e.g. `mr`, `views`), or passes a localized string like `最新`.","solutions":["Use exactly one of: `hot`, `created`, or `replied` as the `:sort` segment.","Omit `:sort` so the destructure default `'created'` applies.","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."],"exampleFix":"// before\n/rsshub/qq/pd/guild/qrp4pkq01d/650967831/latest\n// after\n/rsshub/qq/pd/guild/qrp4pkq01d/650967831/replied","handlingStrategy":"type-guard","validationCode":"const VALID_SORTS = ['hot', 'created', 'replied'] as const;\ntype Sort = typeof VALID_SORTS[number];\nconst sort = ctx.req.param('sort') ?? 'created';\nif (!VALID_SORTS.includes(sort as Sort)) {\n    return ctx.body(`Invalid sort. Use one of: ${VALID_SORTS.join(', ')}`, 400);\n}","typeGuard":"const isSort = (v: unknown): v is 'hot' | 'created' | 'replied' =>\n    v === 'hot' || v === 'created' || v === 'replied';","tryCatchPattern":null,"preventionTips":["Surface the accepted sort values in your client UI.","Default the segment to 'created' to match the route's own default.","Keep VALID_SORTS in sync with sortMap keys via `keyof typeof sortMap`."],"tags":["invalid-parameter","enum-validation","route-validation"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}