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

  1. Provide at least one valid search parameter in the route path, e.g., /discord/search/<guildId>/content=keyword.
  2. Valid parameters are: content, author_id, min_id, max_id, channel_id, pinned.
  3. Ensure parameters are properly formatted as key=value pairs separated by slashes or appropriate delimiters.
  4. 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

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


AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12). Data as JSON: /api/errors/734ff11237ed32cb. Report an issue: GitHub.