DIYgod/RSSHub · warning · InvalidParameterError
请填入合法的类型 id,可选值为 `questions` 即 `主题` 或 `answer` 即 `回复`,默认为空,即
Error message
请填入合法的类型 id,可选值为 `questions` 即 `主题` 或 `answer` 即 `回复`,默认为空,即全部
What it means
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.
Source
Thrown at lib/routes/jisilu/people.ts:22
import type { Context } from 'hono';
import InvalidParameterError from '@/errors/types/invalid-parameter';
import type { Data, DataItem, Language, Route } from '@/types';
import { ViewType } from '@/types';
import ofetch from '@/utils/ofetch';
import { processItems, rootUrl } from './util';
const actions: { [key: string]: string } = {
questions: '101',
answers: '201',
};
export const handler = async (ctx: Context): Promise<Data> => {
const { id, type = 'questions' } = ctx.req.param();
if (type && type !== 'answers' && type !== 'questions') {
throw new InvalidParameterError('请填入合法的类型 id,可选值为 `questions` 即 `主题` 或 `answer` 即 `回复`,默认为空,即全部');
}
const limit = Number(ctx.req.query('limit') ?? '30');
const targetUrl: string = new URL(`/people/${id}`, rootUrl).href;
const response = await ofetch(targetUrl);
const $: CheerioAPI = load(response);
const language: string = $('html').prop('lang') ?? 'zh';
const userId: string | undefined = response.match(/var\sPEOPLE_USER_ID\s=\s'(\d+)';/)?.[1];
if (!userId) {
throw new InvalidParameterError('请填入合法的用户 id,参见用户排名 https://www.jisilu.cn/users/');
}
const apiUrl: string = new URL(`people/ajax/user_actions/uid-${userId}__actions-${actions[type]}__page-1`, rootUrl).href;
const detailResponse = await ofetch(apiUrl);View on GitHub (pinned to bed535e087)
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
Example fix
// before
if (type && type !== 'answers' && type !== 'questions') {
throw new InvalidParameterError('请填入合法的类型 id ...');
}
// after
const validTypes = new Set(['questions', 'answers']);
if (type && !validTypes.has(type)) {
throw new InvalidParameterError(`Invalid type '${type}'. Allowed: questions, answers`);
} Defensive patterns
Strategy: type-guard
Validate before calling
const VALID_TYPES = new Set(['questions', 'answers']);
function isValidPeopleType(t: string | undefined): boolean {
return t === undefined || VALID_TYPES.has(t);
} Type guard
type JisiluPeopleType = 'questions' | 'answers';
function isPeopleType(v: unknown): v is JisiluPeopleType {
return v === 'questions' || v === 'answers';
} Try / catch
try { return await handler(ctx); }
catch (e) {
if (e instanceof InvalidParameterError && /类型 id/.test(e.message)) {
return ctx.json({ error: e.message, allowed: ['questions', 'answers'] }, 400);
}
throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: User guesses a type slug; outdated docs list a third option; URL gets an extra path segment appended.
Related errors
- Bad timeRange range. See <a href="https://docs.rsshub.app/ro
- This category does not exist. Please refer to the documentat
- Invalid category Id: ${categoryId}
- Invalid sort type: ${sortType}
- Invalid time range: ${timeRange}
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/b32aa190333461ac.
Report an issue: GitHub.