{"record":{"id":"07318529ac5c630e","repo":"DIYgod/RSSHub","slug":"invalid-category-categoryparam-valid-categori","errorCode":null,"errorMessage":"Invalid category: ${categoryParam}. Valid categories are: ${Object.keys(CATEGORY_SLUG_TO_ID).join(', ')}","messagePattern":"Invalid category: (.+?)\\. Valid categories are: (.+?)","errorType":"validation","errorClass":"InvalidParameterError","httpStatus":503,"severity":"warning","filePath":"lib/routes/baselang/index.ts","lineNumber":81,"sourceCode":"    },\n    radar: [\n        {\n            source: ['baselang.com/blog', 'baselang.com/blog/:category'],\n            target: '/blog/:category',\n        },\n    ],\n    name: 'Blog',\n    maintainers: ['johan456789'],\n    handler,\n};\n\nasync function handler(ctx: Context): Promise<Data> {\n    const categoryParam = (ctx.req.param('category') ?? '').toLowerCase();\n    logger.debug(`BaseLang: received request, category='${categoryParam || 'all'}'`);\n\n    if (categoryParam && !Object.hasOwn(CATEGORY_SLUG_TO_ID, categoryParam)) {\n        logger.debug(`BaseLang: invalid category '${categoryParam}'`);\n        throw new InvalidParameterError(`Invalid category: ${categoryParam}. Valid categories are: ${Object.keys(CATEGORY_SLUG_TO_ID).join(', ')}`);\n    }\n\n    const searchParams: string[] = ['per_page=20', '_embed=author,wp:term'];\n    if (categoryParam) {\n        const id = CATEGORY_SLUG_TO_ID[categoryParam];\n        searchParams.push(`categories=${id}`);\n    }\n\n    const apiUrl = `${API_BASE}/posts?${searchParams.join('&')}`;\n\n    const data = await ofetch<WordpressPost[]>(apiUrl);\n    logger.debug(`BaseLang: fetched ${data.length} posts`);\n\n    const items = data.map((post) => ({\n        title: post.title?.rendered,\n        description: post.content?.rendered ?? post.excerpt?.rendered ?? '',\n        link: post.link,\n        pubDate: parseDate(post.date_gmt ?? post.date),","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/baselang/index.ts#L63-L99","documentation":"InvalidParameterError thrown by the baselang blog route when an optional :category parameter is supplied but not a key of CATEGORY_SLUG_TO_ID. The route lowercases the param first, then checks Object.hasOwn, so the error lists all valid slugs.","triggerScenarios":"Calling /baselang/blog/:category with a slug not in CATEGORY_SLUG_TO_ID (e.g. 'news', 'spanish', or a typo). Omitting category is fine and returns all posts.","commonSituations":"User guesses a slug that the WordPress site uses but the route never mapped; case differences are already handled by toLowerCase, so this usually means a genuinely unmapped category.","solutions":["Use one of the slugs in the error message (advanced-grammar, basic-grammar, company, confidence, french, humor, medellin, motivation, pronunciation, study-tips, success-stories, travel, uncategorized, vocabulary), or omit the category.","If the WordPress site has a new category, find its WP term id and add it to CATEGORY_SLUG_TO_ID."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const categoryParam = (ctx.req.param('category') ?? '').toLowerCase();\nif (categoryParam && !Object.hasOwn(CATEGORY_SLUG_TO_ID, categoryParam)) {\n    throw new InvalidParameterError(`Invalid category: ${categoryParam}. Valid: ${Object.keys(CATEGORY_SLUG_TO_ID).join(', ')}`);\n}","typeGuard":"function isKnownCategory(slug: string): slug is keyof typeof CATEGORY_SLUG_TO_ID {\n    return Object.prototype.hasOwnProperty.call(CATEGORY_SLUG_TO_ID, slug);\n}","tryCatchPattern":null,"preventionTips":["Lowercase the param before lookup so case variants do not fail.","Expose CATEGORY_OPTIONS via parameters.options so valid slugs are discoverable."],"tags":["baselang","input-validation","wordpress","route-parameter","whitelist"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}