DIYgod/RSSHub · warning · Error
No ${type} found for slug: ${slug}
Error message
No ${type} found for slug: ${slug} What it means
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`.
Source
Thrown at lib/routes/chikubi/utils.ts:115
return ((Array.isArray(cachedData) ? cachedData : []) as Array<DataItem | null>).filter((item): item is DataItem => item !== null);
}
const API_TYPES = {
tag: 'tags',
category: 'categories',
};
export async function getBySlug<T extends keyof typeof API_TYPES>(type: T, slug: string): Promise<{ id: number; name: string }> {
const url = `${WP_REST_API_URL}/${API_TYPES[type]}?slug=${encodeURIComponent(slug)}`;
const { body } = await got(url);
const data = JSON.parse(body);
if (data?.[0]) {
const { id, name } = data[0];
return { id, name };
}
throw new Error(`No ${type} found for slug: ${slug}`);
}
export async function getPostsBy<T extends keyof typeof API_TYPES>(type: T, id: number): Promise<DataItem[]> {
const url = `${WP_REST_API_URL}/posts?${API_TYPES[type]}=${id}`;
const cachedData = await cache.tryGet(url, async () => {
const { body } = await got(url);
const data = JSON.parse(body);
if (Array.isArray(data) && data.length > 0) {
return data.map(({ title, link, date, content }) => ({
title: title.rendered,
link,
pubDate: parseDate(date),
description: processDescription(content.rendered),
}));
}
return [];
});View on GitHub (pinned to bed535e087)
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.
Defensive patterns
Strategy: validation
Validate before calling
const { body } = await got(url);
const data = JSON.parse(body);
if (!Array.isArray(data) || data.length === 0) {
throw new Error(`No ${type} found for slug '${slug}'`);
} Type guard
function isTermArray(r: unknown): r is Array<{ id: number; name: string }> {
return Array.isArray(r) && r.length > 0;
} Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- No posts found for the given IDs
- Invalid URL property: ${prop}
- Invalid Engine Value: ${engine}, please check your config.
- Invalid parameter brief. Please check the doc https://docs.r
- Invalid language code
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/5a08e4f0a1eecd7c.
Report an issue: GitHub.