{"record":{"id":"c46a181f742ad495","repo":"DIYgod/RSSHub","slug":"invalid-id","errorCode":null,"errorMessage":"Invalid id","messagePattern":"Invalid id","errorType":"validation","errorClass":"InvalidParameterError","httpStatus":null,"severity":"warning","filePath":"lib/routes/jiemian/account.ts","lineNumber":34,"sourceCode":"export const route: Route = {\n    path: '/account/main/:id',\n    parameters: { id: '分类 id，见下表，可在对应分类页 URL 中找到' },\n    name: '界面号',\n    example: '/jiemian/account/main/1',\n    maintainers: ['nczitzk', 'pseudoyu'],\n    handler,\n    description: `| [财经号](https://www.jiemian.com/account/main/1.html) | [城市号](https://www.jiemian.com/account/main/2.html) | [媒体号](https://www.jiemian.com/account/main/3.html) |\n| ----------------------------------------------------- | ----------------------------------------------------- | ----------------------------------------------------- |\n| 1                                                     | 2                                                     | 3                                                     |`,\n};\n\nasync function handler(ctx: Context): Promise<Data> {\n    const { id } = ctx.req.param();\n    const limit = ctx.req.query('limit') ? Number(ctx.req.query('limit')) : 10;\n\n    const category = categoryMap[id];\n    if (!category) {\n        throw new InvalidParameterError('Invalid id');\n    }\n\n    const response = await ofetch<string>('https://papi.jiemian.com/page/api/officialAccount/get_index_lists', {\n        query: {\n            ckey: category.ckey,\n            page: 1,\n        },\n    });\n\n    const list = JSON.parse(response.slice(response.indexOf('(') + 1, response.lastIndexOf(')')))\n        .result.slice(0, limit)\n        .map((article) => ({\n            title: article.title,\n            description: article.summary,\n            link: article.url,\n            pubDate: parseDate(article.publish_time, 'X'),\n            author: article.source_name,\n            image: article.image,","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/jiemian/account.ts#L16-L52","documentation":"Thrown by the jiemian (界面新闻) account handler as InvalidParameterError when the `id` path parameter (from /account/main/:id) is not a key of categoryMap. The map only contains '1' (财经号), '2' (城市号), '3' (媒体号), so any other value triggers this. Because categoryMap is keyed by string, a numeric 1 vs '1' also matters.","triggerScenarios":"Request to /jiemian/account/main/4 (or 0, abc, etc.) — any id not in {'1','2','3'}. Also when the route is invoked without an id segment in some misconfigured reverse proxy.","commonSituations":"User guesses a category number; upstream adds a new account type that isn't reflected in categoryMap yet; trailing slash or URL encoding mangles the id.","solutions":["Use one of the documented ids: 1, 2, or 3 — see the route description table","If jiemian added a new account type, add it to categoryMap in lib/routes/jiemian/account.ts:10-14 with its ckey","Confirm the request path matches /jiemian/account/main/:id exactly"],"exampleFix":"// before\nconst category = categoryMap[id];\nif (!category) {\n    throw new InvalidParameterError('Invalid id');\n}\n// after — surface the valid options\nconst category = categoryMap[id];\nif (!category) {\n    throw new InvalidParameterError(`Invalid id '${id}'. Valid ids: ${Object.keys(categoryMap).join(', ')}`);\n}","handlingStrategy":"type-guard","validationCode":"const VALID_IDS = new Set(['1', '2', '3']);\nfunction isValidJiemianId(id: string | undefined): id is '1' | '2' | '3' {\n  return id !== undefined && VALID_IDS.has(id);\n}\n// before calling the handler's ofetch:\nif (!isValidJiemianId(ctx.req.param('id'))) {\n  return ctx.json({ error: 'id must be 1, 2, or 3' }, 400);\n}","typeGuard":"type JiemianId = '1' | '2' | '3';\nfunction isJiemianId(id: unknown): id is JiemianId {\n  return typeof id === 'string' && ['1', '2', '3'].includes(id);\n}","tryCatchPattern":"try {\n  return await handler(ctx);\n} catch (e) {\n  if (e instanceof InvalidParameterError) {\n    return ctx.json({ error: e.message, validIds: ['1', '2', '3'] }, 400);\n  }\n  throw e;\n}","preventionTips":["Validate path params against the categoryMap keys before the handler runs","Document valid ids prominently in the route description","Sync categoryMap with upstream whenever jiemian adds an account type","Reject early at the routing/middleware layer for known-bad ids"],"tags":["validation","parameter","catalog"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}