DIYgod/RSSHub · error · Error

Category not found

Error message

Category not found

What it means

8kcosplay category lookup queries the WordPress REST API /wp-json/wp/v2/categories?slug=… and expects at least one match. It throws a plain `Error('Category not found')` (not InvalidParameterError) when WP returns an empty list. The result is cached under '8kcosplay:category:<slug>' via cache.tryGet.

Source

Thrown at lib/routes/8kcos/utils.ts:36

        title: item.title.rendered,
        description: item.content.rendered,
        link: item.link,
        pubDate: parseDate(item.date_gmt),
        author: item._embedded?.author?.map((a) => a.name).join(', '),
        category: item._embedded?.['wp:term']?.flatMap((terms) => terms.map((t) => t.name)),
    })) satisfies DataItem[];
};

export const getCategoryInfo = (category: string) =>
    cache.tryGet(`8kcosplay:category:${category}`, async () => {
        const data = await ofetch('https://www.8kcosplay.com/wp-json/wp/v2/categories', {
            query: {
                slug: category,
            },
        });
        const categoryInfo = data[0];
        if (!categoryInfo) {
            throw new Error('Category not found');
        }
        return {
            id: categoryInfo.id,
            title: categoryInfo.yoast_head_json.title,
            description: categoryInfo.description,
            link: categoryInfo.link,
        };
    });

export const getTagInfo = (tag: string) =>
    cache.tryGet(`8kcosplay:tag:${tag}`, async () => {
        const data = await ofetch('https://www.8kcosplay.com/wp-json/wp/v2/tags', {
            query: {
                slug: tag,
            },
        });
        const tagInfo = data[0];
        if (!tagInfo) {

View on GitHub (pinned to bed535e087)

Solutions

  1. Confirm the slug exists at https://www.8kcosplay.com/wp-json/wp/v2/categories?slug=<your-slug>.
  2. Invalidate the cache key '8kcosplay:category:<slug>' if a previous bad lookup was cached.
  3. Use the exact lowercase slug shown in the WP term, not its ID.

Example fix

// before
category: 'Cosplay'        // wrong case, WP slug is lowercase
// after
category: 'cosplay'
Defensive patterns

Strategy: try-catch

Validate before calling

// WP slug shape check before the call
function looksLikeWpSlug(s) {
  return typeof s === 'string' && /^[a-z0-9][a-z0-9-]*$/.test(s) && !/^\d+$/.test(s);
}

Type guard

function isWpSlug(s): s is string {
  return typeof s === 'string' && /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/.test(s);
}

Try / catch

try {
  return await getCategoryInfo(slug);
} catch (e) {
  if (e instanceof Error && /Category not found/.test(e.message)) {
    // optional: invalidate cache and retry once in case a stale bad lookup was cached
    await cache.trySet(`8kcosplay:category:${slug}`, async () => /* refetch */ null);
    return null; // or fall back to a known slug
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling the 8kcos category feed with a slug that does not exist on 8kcosplay.com — a typo, a renamed term, or a slug containing spaces/uppercase/ID instead of the slug.

Common situations: Slug copied from a URL that used the numeric term ID; cache poisoning from a previous bad slug (cache.tryGet will replay the throw); WP renamed the term in admin.

Related errors


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