DIYgod/RSSHub · error · InvalidParameterError

Invalid Category: ${category}

Error message

Invalid Category: ${category}

What it means

The i-cable route looks up a WordPress category by slug via the `/categories?slug=<category>` endpoint. If the response array is empty (no matching category) it throws InvalidParameterError echoing the supplied category. Categories are matched by their Chinese slug name (e.g. 新聞資訊, 港聞).

Source

Thrown at lib/routes/i-cable/news.tsx:49

        },
    ],
    name: '新聞',
    maintainers: ['quiniapiezoelectricity'],
    handler,
    url: 'www.i-cable.com/',
    description: `::: tip
分類只可用分類名稱,如:新聞資訊 / 港聞
:::`,
};

async function handler(ctx) {
    const category = ctx.req.param('category') ?? '新聞資訊';
    const limit = ctx.req.query('limit') ?? 20;
    const root = 'https://www.i-cable.com/wp-json/wp/v2';

    const response = await cache.tryGet(`${root}/categories?slug=${category}`, async () => await got(`${root}/categories?slug=${category}`), config.cache.routeExpire, false);
    if (response.data.length < 1) {
        throw new InvalidParameterError(`Invalid Category: ${category}`);
    }
    const metadata = response.data[0];

    const list = await got(`${root}/posts?_embed=1&categories=${metadata.id}&per_page=${limit}`);
    const items = list.data.map((item) => {
        const description = renderToString(
            <>
                {item._embedded['wp:featuredmedia']?.length
                    ? item._embedded['wp:featuredmedia'].map((media) => (
                          <figure>
                              <img src={media.source_url} />
                          </figure>
                      ))
                    : null}
                {item.content.rendered ? raw(item.content.rendered) : null}
            </>
        );
        return {

View on GitHub (pinned to bed535e087)

Solutions

  1. Use the exact Chinese category name as shown in the route's description table (新聞資訊, 港聞, ...).
  2. Verify the slug by browsing i-cable.com and copying the category label.
  3. Default to 新聞資訊 by omitting the segment.

Example fix

// before
//   /i-cable/news/news
// after
//   /i-cable/news/新聞資訊
Defensive patterns

Strategy: validation

Validate before calling

async function categorySlugExists(category: string): Promise<boolean> {
  const { data } = await got(`https://www.i-cable.com/wp-json/wp/v2/categories?slug=${encodeURIComponent(category)}`);
  return data.length > 0;
}

Prevention

When it happens

Trigger: `/i-cable/news/<category>` where <category> is not an existing WP category slug — English names, typos, or renamed categories all produce an empty result.

Common situations: Supplying an English category name instead of the Chinese slug; a typo in the Chinese name; the publisher renamed the category.

Related errors


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