{"record":{"id":"d6045e596a1ba1b1","repo":"DIYgod/RSSHub","slug":"category-categoryslug-not-found-d6045e","errorCode":null,"errorMessage":"Category \"${categorySlug}\" not found","messagePattern":"Category \"(.+?)\" not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/routes/thegadgetflow/rss.tsx","lineNumber":49,"sourceCode":"    handler,\n};\n\nasync function handler(ctx) {\n    const baseUrl = 'https://thegadgetflow.com';\n    const categoryApiPath = '/wp-json/wp/v2/categories';\n    const postApiPath = '/wp-json/wp/v2/posts';\n\n    // get category number\n    const categorySlug = ctx.req.param('category') || '';\n\n    let category;\n    if (categorySlug) {\n        category = await cache.tryGet(`${baseUrl}${categoryApiPath}`, async () => {\n            const { data } = await got(`${baseUrl}${categoryApiPath}`, {\n                searchParams: { slug: categorySlug },\n            });\n            if (!data || data.length === 0) {\n                throw new Error(`Category \"${categorySlug}\" not found`);\n            }\n            return data[0];\n        });\n    }\n\n    const categoryId = category?.id;\n    const categoryName = category?.name;\n    const categoryLink = category?.link;\n\n    // get posts\n    const postsUrl = `${baseUrl}${postApiPath}`;\n    const postsResponse = await got(postsUrl, {\n        searchParams: {\n            per_page: ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 10,\n            _embed: '',\n            ...(categoryId && { categories: categoryId }),\n        },\n    });","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/thegadgetflow/rss.tsx#L31-L67","documentation":"Thrown at lib/routes/thegadgetflow/rss.tsx:49 when the WordPress REST API endpoint `/wp-json/wp/v2/categories?slug={categorySlug}` returns an empty array, meaning no category on thegadgetflow.com matches the provided slug. The result is cached via cache.tryGet keyed on the full categories API URL. It uses a generic `Error` instead of `InvalidParameterError`.","triggerScenarios":"Requesting `/thegadgetflow/typo-slug`; the category was renamed or removed by the site admin; trailing slash or URL-encoded characters in the slug; the slug uses spaces or uppercase that WordPress normalized differently.","commonSituations":"User copies a category display name instead of the URL slug; old bookmarked RSS URL pointing to a deleted category; WordPress permalink structure change.","solutions":["Browse thegadgetflow.com, find the category page, and copy the exact slug from the URL (e.g. `/categories/cool-gadgets-gifts` → slug is `cool-gadgets-gifts`).","Clear the cache key `https://thegadgetflow.com/wp-json/wp/v2/categories` if a previously-failing slug has since been created.","If maintaining the route, replace `throw new Error(...)` with `throw new InvalidParameterError(...)` for proper HTTP 400 semantics."],"exampleFix":"// before\nif (!data || data.length === 0) {\n    throw new Error(`Category \"${categorySlug}\" not found`);\n}\n\n// after\nimport InvalidParameterError from '@/errors/types/invalid-parameter';\n// ...\nif (!data || data.length === 0) {\n    throw new InvalidParameterError(`Category \"${categorySlug}\" not found`);\n}","handlingStrategy":"validation","validationCode":"const response = await got(`https://thegadgetflow.com/wp-json/wp/v2/categories`, {\n    searchParams: { slug: categorySlug },\n});\nif (!response.data || response.data.length === 0) {\n    // slug is invalid; do not proceed to the route\n    throw new Error(`Category slug \"${categorySlug}\" does not exist on thegadgetflow.com`);\n}","typeGuard":"const isWpCategory = (d: unknown): d is { id: number; name: string; link: string } =>\n    !!d && typeof d === 'object' && 'id' in d && 'name' in d;","tryCatchPattern":null,"preventionTips":["Copy the slug directly from the thegadgetflow.com category URL, not the display name.","Slugs are lowercase, hyphen-separated — never use spaces or uppercase.","Cache the category lookup result to avoid repeated API calls for the same slug."],"tags":["validation","parameters","wordpress","api"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}