DIYgod/RSSHub · warning · InvalidParameterError
请填入合法的分类 id,参见广场 https://www.jisilu.cn/explore/
Error message
请填入合法的分类 id,参见广场 https://www.jisilu.cn/explore/
What it means
Thrown by the jisilu (集思录) category handler as InvalidParameterError when the `id` path parameter is falsy (empty string, undefined). The handler builds `/category/${id}` against rootUrl, so an empty id would produce a malformed URL; the guard rejects it before the request is made.
Source
Thrown at lib/routes/jisilu/category.ts:16
import type { CheerioAPI } from 'cheerio';
import { load } from 'cheerio';
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';
export const handler = async (ctx: Context): Promise<Data> => {
const { id } = ctx.req.param();
if (!id) {
throw new InvalidParameterError('请填入合法的分类 id,参见广场 https://www.jisilu.cn/explore/');
}
const limit = Number(ctx.req.query('limit') ?? '30');
const targetUrl: string = new URL(`/category/${id}`, rootUrl).href;
const response = await ofetch(targetUrl);
const $: CheerioAPI = load(response);
const language: string = $('html').prop('lang') ?? 'zh';
const items: DataItem[] = await processItems($, $('div.aw-question-list'), limit);
$('div.pagination').remove();
const author = $('meta[name="keywords"]').prop('content').split(/,/, 1)[0];
const feedImage = $('div.aw-logo img').prop('src');
return {View on GitHub (pinned to bed535e087)
Solutions
- Provide a valid category slug from https://www.jisilu.cn/explore/ — e.g. /jisilu/category/fund
- Confirm the route path /jisilu/category/:id is fully populated
- If a non-empty-but-wrong id slips through, add a post-fetch empty-result check as a second guard
Example fix
// before
if (!id) {
throw new InvalidParameterError('请填入合法的分类 id,参见广场 https://www.jisilu.cn/explore/');
}
// after — also validate against a known set if maintained
const KNOWN = new Set(['fund', 'stock', 'bond', 'lof', ...]);
if (!id || !KNOWN.has(id)) {
throw new InvalidParameterError(`请填入合法的分类 id,参见广场 https://www.jisilu.cn/explore/ (got '${id ?? ''}')`);
} Defensive patterns
Strategy: validation
Validate before calling
function hasCategoryId(id: string | undefined): id is string {
return typeof id === 'string' && id.trim().length > 0;
}
if (!hasCategoryId(ctx.req.param('id'))) {
return ctx.json({ error: 'category id required' }, 400);
} Type guard
function isNonEmptyString(v: unknown): v is string {
return typeof v === 'string' && v.trim().length > 0;
} Try / catch
try {
return await handler(ctx);
} catch (e) {
if (e instanceof InvalidParameterError && /分类 id/.test(e.message)) {
return ctx.json({ error: e.message }, 400);
}
throw e;
} Prevention
- Make path params required (non-optional) in the route definition where possible
- Trim input before validation
- Add a secondary post-fetch empty-result guard for non-empty-but-wrong ids
- Link users to the explore page in the error message
When it happens
Trigger: Request to /jisilu/category/ with no id segment, or an id that evaluates to empty string (e.g. a lone slash or whitespace). Note: only a truly empty id is rejected — a non-existent but non-empty category id passes this check and fails later during parsing.
Common situations: Misrouted request missing the id; user constructs the URL by hand and omits the category; reverse-proxy rewrite strips the segment.
Related errors
- Bad timeRange range. See <a href="https://docs.rsshub.app/ro
- Bad parameter. See <a href="https://docs.rsshub.app/routes/g
- Invalid city
- Invalid channel name
- This category does not exist. Please refer to the documentat
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/99a048079da0e997.
Report an issue: GitHub.