{"record":{"id":"489e0d1de5950539","repo":"DIYgod/RSSHub","slug":"category-not-found","errorCode":null,"errorMessage":"Category not found","messagePattern":"Category not found","errorType":"exception","errorClass":"Error","httpStatus":503,"severity":"error","filePath":"lib/routes/8kcos/utils.ts","lineNumber":36,"sourceCode":"        title: item.title.rendered,\n        description: item.content.rendered,\n        link: item.link,\n        pubDate: parseDate(item.date_gmt),\n        author: item._embedded?.author?.map((a) => a.name).join(', '),\n        category: item._embedded?.['wp:term']?.flatMap((terms) => terms.map((t) => t.name)),\n    })) satisfies DataItem[];\n};\n\nexport const getCategoryInfo = (category: string) =>\n    cache.tryGet(`8kcosplay:category:${category}`, async () => {\n        const data = await ofetch('https://www.8kcosplay.com/wp-json/wp/v2/categories', {\n            query: {\n                slug: category,\n            },\n        });\n        const categoryInfo = data[0];\n        if (!categoryInfo) {\n            throw new Error('Category not found');\n        }\n        return {\n            id: categoryInfo.id,\n            title: categoryInfo.yoast_head_json.title,\n            description: categoryInfo.description,\n            link: categoryInfo.link,\n        };\n    });\n\nexport const getTagInfo = (tag: string) =>\n    cache.tryGet(`8kcosplay:tag:${tag}`, async () => {\n        const data = await ofetch('https://www.8kcosplay.com/wp-json/wp/v2/tags', {\n            query: {\n                slug: tag,\n            },\n        });\n        const tagInfo = data[0];\n        if (!tagInfo) {","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/8kcos/utils.ts#L18-L54","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Confirm the slug exists at https://www.8kcosplay.com/wp-json/wp/v2/categories?slug=<your-slug>.","Invalidate the cache key '8kcosplay:category:<slug>' if a previous bad lookup was cached.","Use the exact lowercase slug shown in the WP term, not its ID."],"exampleFix":"// before\ncategory: 'Cosplay'        // wrong case, WP slug is lowercase\n// after\ncategory: 'cosplay'","handlingStrategy":"try-catch","validationCode":"// WP slug shape check before the call\nfunction looksLikeWpSlug(s) {\n  return typeof s === 'string' && /^[a-z0-9][a-z0-9-]*$/.test(s) && !/^\\d+$/.test(s);\n}","typeGuard":"function isWpSlug(s): s is string {\n  return typeof s === 'string' && /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/.test(s);\n}","tryCatchPattern":"try {\n  return await getCategoryInfo(slug);\n} catch (e) {\n  if (e instanceof Error && /Category not found/.test(e.message)) {\n    // optional: invalidate cache and retry once in case a stale bad lookup was cached\n    await cache.trySet(`8kcosplay:category:${slug}`, async () => /* refetch */ null);\n    return null; // or fall back to a known slug\n  }\n  throw e;\n}","preventionTips":["Use the slug from /wp-json/wp/v2/categories, never the numeric term ID.","Invalidate the cache key after correcting a bad slug.","Note this throws a plain Error, not InvalidParameterError — match on the message text."],"tags":["upstream-dependent","wordpress","cache","rsshub","error-class-mismatch"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}