{"record":{"id":"b32aa190333461ac","repo":"DIYgod/RSSHub","slug":"id-questions-answer","errorCode":null,"errorMessage":"请填入合法的类型 id，可选值为 `questions` 即 `主题` 或 `answer` 即 `回复`，默认为空，即全部","messagePattern":"请填入合法的类型 id，可选值为 `questions` 即 `主题` 或 `answer` 即 `回复`，默认为空，即全部","errorType":"validation","errorClass":"InvalidParameterError","httpStatus":null,"severity":"warning","filePath":"lib/routes/jisilu/people.ts","lineNumber":22,"sourceCode":"import type { Context } from 'hono';\n\nimport InvalidParameterError from '@/errors/types/invalid-parameter';\nimport type { Data, DataItem, Language, Route } from '@/types';\nimport { ViewType } from '@/types';\nimport ofetch from '@/utils/ofetch';\n\nimport { processItems, rootUrl } from './util';\n\nconst actions: { [key: string]: string } = {\n    questions: '101',\n    answers: '201',\n};\n\nexport const handler = async (ctx: Context): Promise<Data> => {\n    const { id, type = 'questions' } = ctx.req.param();\n\n    if (type && type !== 'answers' && type !== 'questions') {\n        throw new InvalidParameterError('请填入合法的类型 id，可选值为 `questions` 即 `主题` 或 `answer` 即 `回复`，默认为空，即全部');\n    }\n\n    const limit = Number(ctx.req.query('limit') ?? '30');\n\n    const targetUrl: string = new URL(`/people/${id}`, rootUrl).href;\n\n    const response = await ofetch(targetUrl);\n    const $: CheerioAPI = load(response);\n    const language: string = $('html').prop('lang') ?? 'zh';\n    const userId: string | undefined = response.match(/var\\sPEOPLE_USER_ID\\s=\\s'(\\d+)';/)?.[1];\n\n    if (!userId) {\n        throw new InvalidParameterError('请填入合法的用户 id，参见用户排名 https://www.jisilu.cn/users/');\n    }\n\n    const apiUrl: string = new URL(`people/ajax/user_actions/uid-${userId}__actions-${actions[type]}__page-1`, rootUrl).href;\n\n    const detailResponse = await ofetch(apiUrl);","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/jisilu/people.ts#L4-L40","documentation":"Thrown by the jisilu people handler as InvalidParameterError when the `type` parameter (defaulting to 'questions') is set to anything other than 'questions' or 'answers'. The handler maps these to internal action codes (questions→101, answers→201) used in the user-actions AJAX URL, so any other type would build a broken endpoint.","triggerScenarios":"Request like /jisilu/people/<id>/comments or /jisilu/people/<id>/replies where the third segment is not 'questions' or 'answers'. The default is 'questions', so omitting type is safe.","commonSituations":"User guesses a type slug; outdated docs list a third option; URL gets an extra path segment appended.","solutions":["Omit the type segment (defaults to 'questions') or use exactly 'questions' or 'answers'","If you need a new action type, add it to the `actions` map in lib/routes/jisilu/people.ts:5-8 and update the guard","Check the route definition's parameters description for the allowed enum"],"exampleFix":"// before\nif (type && type !== 'answers' && type !== 'questions') {\n    throw new InvalidParameterError('请填入合法的类型 id ...');\n}\n// after\nconst validTypes = new Set(['questions', 'answers']);\nif (type && !validTypes.has(type)) {\n    throw new InvalidParameterError(`Invalid type '${type}'. Allowed: questions, answers`);\n}","handlingStrategy":"type-guard","validationCode":"const VALID_TYPES = new Set(['questions', 'answers']);\nfunction isValidPeopleType(t: string | undefined): boolean {\n  return t === undefined || VALID_TYPES.has(t);\n}","typeGuard":"type JisiluPeopleType = 'questions' | 'answers';\nfunction isPeopleType(v: unknown): v is JisiluPeopleType {\n  return v === 'questions' || v === 'answers';\n}","tryCatchPattern":"try { return await handler(ctx); }\ncatch (e) {\n  if (e instanceof InvalidParameterError && /类型 id/.test(e.message)) {\n    return ctx.json({ error: e.message, allowed: ['questions', 'answers'] }, 400);\n  }\n  throw e;\n}","preventionTips":["Default the type param so omitting it is always valid","Keep the `actions` map and the validation enum in sync (single source)","Expose allowed values in the error message","Validate before building the AJAX URL"],"tags":["validation","parameter","enum"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}