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

  1. Confirm the slug exists: open `https://chikubi.jp/wp-json/wp/v2/categories?slug=<slug>` (or `tags`) and check the array is non-empty.
  2. Use the exact WP slug (lowercase, hyphen-separated), not the display name.
  3. 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

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


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