{"record":{"id":"5a08e4f0a1eecd7c","repo":"DIYgod/RSSHub","slug":"no-type-found-for-slug-slug","errorCode":null,"errorMessage":"No ${type} found for slug: ${slug}","messagePattern":"No (.+?) found for slug: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"lib/routes/chikubi/utils.ts","lineNumber":115,"sourceCode":"\n    return ((Array.isArray(cachedData) ? cachedData : []) as Array<DataItem | null>).filter((item): item is DataItem => item !== null);\n}\n\nconst API_TYPES = {\n    tag: 'tags',\n    category: 'categories',\n};\n\nexport async function getBySlug<T extends keyof typeof API_TYPES>(type: T, slug: string): Promise<{ id: number; name: string }> {\n    const url = `${WP_REST_API_URL}/${API_TYPES[type]}?slug=${encodeURIComponent(slug)}`;\n    const { body } = await got(url);\n    const data = JSON.parse(body);\n\n    if (data?.[0]) {\n        const { id, name } = data[0];\n        return { id, name };\n    }\n    throw new Error(`No ${type} found for slug: ${slug}`);\n}\n\nexport async function getPostsBy<T extends keyof typeof API_TYPES>(type: T, id: number): Promise<DataItem[]> {\n    const url = `${WP_REST_API_URL}/posts?${API_TYPES[type]}=${id}`;\n    const cachedData = await cache.tryGet(url, async () => {\n        const { body } = await got(url);\n        const data = JSON.parse(body);\n\n        if (Array.isArray(data) && data.length > 0) {\n            return data.map(({ title, link, date, content }) => ({\n                title: title.rendered,\n                link,\n                pubDate: parseDate(date),\n                description: processDescription(content.rendered),\n            }));\n        }\n        return [];\n    });","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/chikubi/utils.ts#L97-L133","documentation":"Thrown by `getBySlug` in chikubi/utils.ts when the WordPress REST API returns an empty array (or falsy first element) for a tag/category slug lookup. The route resolves slugs (human names) to numeric WP ids; if WP has no matching term, the lookup fails. Plain `Error`.","triggerScenarios":"Calling the route with a slug that does not exist on chikubi.jp's WP taxonomy, a typo in the slug, or URL-encoding issues (slug is `encodeURIComponent`-ed, so a `%20` may not match a `-`-joined slug).","commonSituations":"User guesses a tag name, copies a Japanese display name with spaces instead of the WP slug, or the tag was renamed/deleted on the site.","solutions":["Confirm the slug exists: open `https://chikubi.jp/wp-json/wp/v2/categories?slug=<slug>` (or `tags`) and check the array is non-empty.","Use the exact WP slug (lowercase, hyphen-separated), not the display name.","Maintainers: distinguish 'not found' (empty array) from 'WP error' (object body) for clearer messaging."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const { body } = await got(url);\nconst data = JSON.parse(body);\nif (!Array.isArray(data) || data.length === 0) {\n    throw new Error(`No ${type} found for slug '${slug}'`);\n}","typeGuard":"function isTermArray(r: unknown): r is Array<{ id: number; name: string }> {\n    return Array.isArray(r) && r.length > 0;\n}","tryCatchPattern":null,"preventionTips":["Look up the slug directly via `/wp-json/wp/v2/<taxonomy>?slug=<slug>` to confirm it exists.","Use the exact WP slug (lowercase, hyphenated), not the display name with spaces.","URL-decode the slug before validating if it came through a URL."],"tags":["validation","upstream-api","wordpress-rest","slug-lookup"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}