DIYgod/RSSHub · warning · InvalidParameterError
At least one valid search parameter is required
Error message
At least one valid search parameter is required
What it means
The Discord search route accepts routeParams (URL path parameters) that are parsed into search parameters: content, author_id, min_id, max_id, channel_id, and pinned. If none of these are provided or all are undefined after parsing, an InvalidParameterError is thrown because Discord's search API requires at least one search criterion.
Source
Thrown at lib/routes/discord/search.ts:67
max_id: parsed.get('max_id') ?? undefined,
channel_id: parsed.get('channel_id') ?? undefined,
pinned: parsed.has('pinned') ? queryToBoolean(parsed.get('pinned')) : undefined,
};
return Object.fromEntries(Object.entries(params).filter(([, value]) => value !== undefined));
};
async function handler(ctx) {
const { authorization } = config.discord || {};
if (!authorization) {
throw new ConfigNotFoundError('Discord RSS is disabled due to the lack of authorization config');
}
const { guildId } = ctx.req.param();
const searchParams = parseSearchParams(ctx.req.param('routeParams'));
if (!Object.keys(searchParams).length) {
throw new InvalidParameterError('At least one valid search parameter is required');
}
const [guildInfo, searchResult] = await Promise.all([getGuild(guildId, authorization), searchGuildMessages(guildId, authorization, searchParams)]);
if (!searchResult?.messages?.length) {
return {
title: `Search Results - ${guildInfo.name}`,
link: `${baseUrl}/channels/${guildId}`,
item: [],
allowEmpty: true,
};
}
const messages = searchResult.messages.flat().map((message) => ({
title: message.content.split('\n', 1)[0] || '(no content)',
description: renderDescription({ message, guildInfo }),
author: message.author.global_name ?? message.author.username,
pubDate: parseDate(message.timestamp),View on GitHub (pinned to bed535e087)
Solutions
- Provide at least one valid search parameter in the route path, e.g., /discord/search/<guildId>/content=keyword.
- Valid parameters are: content, author_id, min_id, max_id, channel_id, pinned.
- Ensure parameters are properly formatted as key=value pairs separated by slashes or appropriate delimiters.
- Check the route documentation for the exact routeParams format.
Defensive patterns
Strategy: validation
Validate before calling
const searchParams = parseSearchParams(ctx.req.param('routeParams'));
const validParams = ['content', 'author_id', 'min_id', 'max_id', 'channel_id', 'pinned'];
if (!Object.keys(searchParams).length) {
throw new InvalidParameterError(`At least one search parameter required. Valid params: ${validParams.join(', ')}. Example: /discord/search/<guildId>/content=hello`);
} Type guard
function hasSearchParams(params: Record<string, unknown>): boolean {
return Object.keys(params).length > 0;
} Prevention
- Always include at least one search parameter in the route path.
- Review valid parameter names before constructing the route URL.
- Test the routeParams encoding to ensure parameters are parsed correctly.
When it happens
Trigger: The user accesses /discord/search/:guildId/:routeParams where routeParams is empty or contains only unrecognized keys. parseSearchParams filters out undefined values, and if Object.keys(searchParams).length is 0, the error fires. This is a user-input validation error, not a config or API issue.
Common situations: User omits the routeParams segment entirely; user provides only invalid parameters that get filtered out; user provides parameters with empty values (e.g., 'content=') which become undefined; the routeParams encoding is incorrect (not properly URL-encoded key=value pairs).
Related errors
- Invalid category
- 无法检测 Discuz 版本,请在路由中指定版本参数,如 /discuz/x/ 或 /discuz/7/
- 通知类型${typeParam}未定义
- Unsupported language: ${language}
- Invalid type or subtype
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/734ff11237ed32cb.
Report an issue: GitHub.