DIYgod/RSSHub · warning · InvalidParameterError

No category '${category}'.

Error message

No category '${category}'.

What it means

Thrown as an `InvalidParameterError` when the `category` path parameter (case-insensitive) is not a key in the `categories` object `{news: 0, blogs: 1}`. The check uses `Object.hasOwn(categories, category.toLowerCase())`. The default is `'News'`. This is pre-flight validation before fetching finviz.com/news.ashx.

Source

Thrown at lib/routes/finviz/news.ts:53

        {
            source: ['finviz.com/news.ashx', 'finviz.com/'],
        },
    ],
    name: 'News',
    maintainers: ['nczitzk'],
    handler,
    url: 'finviz.com/news.ashx',
    description: `| News | Blogs |
| ---- | ----- |
| news | blogs |`,
};

async function handler(ctx) {
    const { category = 'News' } = ctx.req.param();
    const limit = ctx.req.query('limit') ? Number(ctx.req.query('limit')) : 200;

    if (!Object.hasOwn(categories, category.toLowerCase())) {
        throw new InvalidParameterError(`No category '${category}'.`);
    }

    const rootUrl = 'https://finviz.com';
    const currentUrl = new URL('news.ashx', rootUrl).href;

    const { data: response } = await got(currentUrl);

    const $ = load(response);

    const items = $('table.table-fixed')
        .eq(categories[category.toLowerCase()])
        .find('tr')
        .slice(0, limit)
        .toArray()
        .map((item) => {
            const $item = $(item);

            const a = $item.find('a.nn-tab-link');

View on GitHub (pinned to bed535e087)

Solutions

  1. Use `news` or `blogs` as the category (case-insensitive).
  2. Omit the category parameter to default to `News`.
  3. Check the route description table for the valid options.
Defensive patterns

Strategy: validation

Validate before calling

const categories = { news: 0, blogs: 1 };

function validateCategory(category: string | undefined): string {
    const resolved = (category ?? 'news').toLowerCase();
    if (!Object.hasOwn(categories, resolved)) {
        throw new InvalidParameterError(`No category '${category}'. Valid: news, blogs`);
    }
    return resolved;
}

Type guard

function isFinvizCategory(category: string): boolean {
    return Object.hasOwn({ news: 0, blogs: 1 }, category.toLowerCase());
}

Prevention

When it happens

Trigger: A user requests `/finviz/<category>` where `<category>` is not `news` or `blogs` (case-insensitive) — e.g., `/finviz/stocks`, `/finviz/forex`, or `/finviz/articles`. The hasOwn check fails immediately.

Common situations: User assumes Finviz has more categories than it does. User passes a Finviz page name from a different part of the site (e.g., `screener`, `insider`). The user includes uppercase characters which are handled by toLowerCase() but the underlying value is still invalid.

Related errors


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