{"record":{"id":"45ea13e1b4d1d066","repo":"DIYgod/RSSHub","slug":"invalid-rank-type","errorCode":null,"errorMessage":"Invalid rank type","messagePattern":"Invalid rank type","errorType":"validation","errorClass":"InvalidParameterError","httpStatus":503,"severity":"error","filePath":"lib/routes/xsijishe/rank.ts","lineNumber":60,"sourceCode":"    },\n    name: '排行榜',\n    maintainers: ['akynazh', 'AiraNadih'],\n    handler,\n};\n\nasync function handler(ctx) {\n    const rankType = ctx.req.param('type');\n    let title;\n    let index;\n\n    if (rankType === 'weekly') {\n        title = '司机社综合周排行榜';\n        index = 0;\n    } else if (rankType === 'monthly') {\n        title = '司机社综合月排行榜';\n        index = 1;\n    } else {\n        throw new InvalidParameterError('Invalid rank type');\n    }\n\n    const context = await playwright();\n    const url = `${baseUrl}/portal.php`;\n    try {\n        const data = await playwrightGet(url, context, '.nex_recon_lists', {\n            cookie: config.xsijishe.cookie,\n            userAgent: config.xsijishe.userAgent,\n        });\n        const $ = load(data);\n        const items = $('.nex_recon_lists ul li')\n            .eq(index)\n            .find('.nex_recons_demens dl dd')\n            .toArray()\n            .map((item) => {\n                const $item = $(item);\n                const title = $item.find('h5').text().trim();\n                const link = $item.find('a').attr('href');","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/xsijishe/rank.ts#L42-L78","documentation":"InvalidParameterError thrown by the xsijishe rank handler when ctx.req.param('type') is neither 'weekly' nor 'monthly' — the only two leaderboards the site exposes. The type maps to both a display title and a list index (0 or 1) used to select the correct ul li element via .eq(index).","triggerScenarios":"A request to /xsijishe/rank/:type where type is not 'weekly' or 'monthly' (e.g. /xsijishe/rank/daily, /xsijishe/rank/yearly). Validated before launching Playwright, so no browser session is wasted.","commonSituations":"Caller assumed more granular timeframes exist; typo; integrator copied a type from another BBS route.","solutions":["Use 'weekly' or 'monthly'.","Confirm the site still offers both boards by visiting the portal.php page; if it changed, update the if/else chain and the index mapping."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const RANK_TYPES = { weekly: { title: '司机社综合周排行榜', index: 0 }, monthly: { title: '司机社综合月排行榜', index: 1 } } as const;\nfunction resolveRankType(raw: string) {\n    if (!Object.hasOwn(RANK_TYPES, raw)) {\n        throw new InvalidParameterError(`Invalid rank type \"${raw}\". Use 'weekly' or 'monthly'.`);\n    }\n    return RANK_TYPES[raw as keyof typeof RANK_TYPES];\n}","typeGuard":"function isRankType(value: string): value is 'weekly' | 'monthly' {\n    return value === 'weekly' || value === 'monthly';\n}","tryCatchPattern":null,"preventionTips":["Drive title+index from a single lookup table to keep them in sync.","Document the two valid values in the route parameters options (already done)."],"tags":["xsijishe","validation","route-param"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}