DIYgod/RSSHub · error · Error

Invalid tab: ${tab}

Error message

Invalid tab: ${tab}

What it means

Thrown by the Voronoi popular route handler when the `tab` path parameter, after lowercasing, is not a key in `TabMap` (`most-popular`, `most-discussed`, `most-viewed`). This is the route-level guard (line 34) that runs before calling `getPostItems`. It uses `Object.hasOwn(TabMap, tab.toLowerCase())`. This is a generic `Error`.

Source

Thrown at lib/routes/voronoiapp/popular.ts:35

            source: ['www.voronoiapp.com/posts/most-discussed'],
            target: '/popular/most-discussed',
        },
        {
            title: 'Most Viewed Posts',
            source: ['www.voronoiapp.com/posts/most-viewed'],
            target: '/popular/most-viewed',
        },
    ],
    parameters: {
        tab: TabParam,
        time_range: TimeRangeParam,
        category: CategoryParam,
    },
    example: '/voronoiapp/popular/most-popular/MONTH',
    handler: async (ctx) => {
        const { tab = 'most-popular', time_range = 'MONTH', category = '' } = ctx.req.param();
        if (!Object.hasOwn(TabMap, tab.toLowerCase())) {
            throw new Error(`Invalid tab: ${tab}`);
        }
        const items = await getPostItems({
            swimlane: 'POPULAR',
            tab: TabMap[tab.toLowerCase()],
            time_range: time_range === '' ? undefined : time_range.toUpperCase(),
            category: category === '' ? undefined : category,
        });
        return {
            ...CommonDataProperties,
            title: `Voronoi ${TabParam.options.find((option) => option.value === tab.toLowerCase())?.label} Posts in ${TimeRangeParam.options.find((option) => option.value === time_range.toUpperCase())?.label}${category ? ` - ${category}` : ''}`,
            link: `https://www.voronoiapp.com/posts/${tab}`,
            item: items,
        } as Data;
    },
};

View on GitHub (pinned to bed535e087)

Solutions

  1. Use one of the lowercase tab keys: `most-popular`, `most-discussed`, or `most-viewed`.
  2. Omit the tab parameter to default to `most-popular`.
  3. Check the TabParam description table for valid values.

Example fix

// before
GET /voronoiapp/popular/trending
// after
GET /voronoiapp/popular/most-popular
Defensive patterns

Strategy: validation

Validate before calling

if (!Object.hasOwn(TabMap, tab.toLowerCase())) {
    throw new InvalidParameterError(
        `Invalid tab: ${tab}. Valid: ${Object.keys(TabMap).join(', ')}`
    );
}

Type guard

function isValidPopularTab(tab: string): tab is 'most-popular' | 'most-discussed' | 'most-viewed' {
    return Object.hasOwn(TabMap, tab.toLowerCase());
}

Prevention

When it happens

Trigger: A request to `/voronoiapp/popular/:tab` where `:tab` is not `most-popular`, `most-discussed`, or `most-viewed`. The parameter defaults to `most-popular`, so omitting it is safe. Only an explicit invalid value triggers the error.

Common situations: User guesses a tab name like `top` or `trending`, or uses the uppercase API value `POPULAR` instead of the lowercase path key `most-popular`.

Related errors


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