DIYgod/RSSHub · warning · InvalidParameterError

Invalid section: ${sectionParam}. Valid sections are: ${Obje

Error message

Invalid section: ${sectionParam}. Valid sections are: ${Object.keys(SECTION_LABELS).join(', ')}

What it means

Thrown by the Hudson River Trading tech blog route when the `:section` path parameter is non-empty but does not match any key in `SECTION_CATEGORY_IDS` (algo, engineers, interns) and is not the special value `more`. The route uses WordPress REST API category IDs to filter posts. The error message lists all valid section keys from `SECTION_LABELS`.

Source

Thrown at lib/routes/hudsonrivertrading/index.ts:84

| /hudsonrivertrading/blog | All Posts |
${Object.entries(SECTION_LABELS)
    .map(([key, label]) => `| /hudsonrivertrading/blog/${key} | ${label} |`)
    .join('\n')}`,
};

async function handler(ctx): Promise<Data> {
    const sectionParam = (ctx.req.param('section') ?? '').toLowerCase();
    const apiBase = `${ROOT_URL}/wp-json/wp/v2`;

    // Build query using fixed category IDs
    let categoriesQuery: { include?: number; exclude?: number[] } | undefined;
    if (sectionParam) {
        if (Object.hasOwn(SECTION_CATEGORY_IDS, sectionParam)) {
            categoriesQuery = { include: SECTION_CATEGORY_IDS[sectionParam] };
        } else if (sectionParam === 'more') {
            categoriesQuery = { exclude: Object.values(SECTION_CATEGORY_IDS) };
        } else {
            throw new InvalidParameterError(`Invalid section: ${sectionParam}. Valid sections are: ${Object.keys(SECTION_LABELS).join(', ')}`);
        }
    }
    // If sectionParam is empty/undefined, categoriesQuery remains undefined = all posts

    const searchParams: string[] = ['per_page=20', '_embed=author,wp:term'];
    if (categoriesQuery?.include) {
        searchParams.push(`categories=${categoriesQuery.include}`);
    }
    if (categoriesQuery?.exclude?.length) {
        searchParams.push(`categories_exclude=${categoriesQuery.exclude.join(',')}`);
    }

    const apiUrl = `${apiBase}/posts?${searchParams.join('&')}`;
    const data = await ofetch<WordpressPost[]>(apiUrl);

    const items = data.map((post) => ({
        title: post.title?.rendered,
        description: post.content?.rendered ?? post.excerpt?.rendered ?? '',

View on GitHub (pinned to bed535e087)

Solutions

  1. Use one of: `algo`, `engineers`, `interns`, or `more`.
  2. Omit the section entirely to get all posts: `/hudsonrivertrading/blog`.

Example fix

// before (broken)
// GET /hudsonrivertrading/blog/intern

// after (correct)
// GET /hudsonrivertrading/blog/interns
Defensive patterns

Strategy: validation

Validate before calling

const VALID_SECTIONS = Object.keys(SECTION_LABELS); // ['algo', 'engineers', 'interns', 'more']
function isValidSection(section: string): boolean {
    return VALID_SECTIONS.includes(section.toLowerCase());
}

Type guard

function isValidHrtSection(section: string): section is 'algo' | 'engineers' | 'interns' | 'more' {
    return section.toLowerCase() in SECTION_LABELS;
}

Prevention

When it happens

Trigger: Requesting `/hudsonrivertrading/blog/<section>` where `<section>` is not `algo`, `engineers`, `interns`, or `more`. The parameter is case-insensitive (lowercased at line 73) but must match one of those four exact strings.

Common situations: Typo in the section name, using a plural or variant (e.g. `intern`, `engineering`), or guessing a section that doesn't exist. The `parameters.options` field in the route config enumerates valid values for documentation.

Related errors


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