{"record":{"id":"3a146084ed45679d","repo":"DIYgod/RSSHub","slug":"invalid-category-category-3a1460","errorCode":null,"errorMessage":"Invalid category: ${category}","messagePattern":"Invalid category: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"lib/routes/lemonde/en.ts","lineNumber":159,"sourceCode":"| science                 | Science                   |\n| health                  | Health                    |\n| intimacy                | Intimacy                  |\n| les-decodeurs           | Les Décodeurs             |\n| our-times               | Our Times                 |\n| obituaries              | Obituaries                |\n| religion                | Religion                  |\n| opinion                 | Opinion                   |\n| editorials              | Opinion – Editorials      |\n| columns                 | Opinion – Columns         |\n| op-eds                  | Opinion – Op-Eds          |`,\n};\n\nasync function handler(ctx) {\n    const category = ctx.req.param('category') ?? '';\n    const feedUrl = feedMap[category];\n\n    if (!feedUrl) {\n        throw new Error(`Invalid category: ${category}`);\n    }\n\n    const xml = await ofetch(feedUrl);\n    const $ = load(xml, { xml: true });\n\n    const channel = $('channel');\n    const feedTitle = channel.children('title').text();\n    const feedLink = channel.children('link').text() || ROOT_URL;\n\n    const limit = ctx.req.query('limit') ? Number(ctx.req.query('limit')) : 20;\n\n    const items = $('item')\n        .toArray()\n        .slice(0, limit)\n        .map((el) => {\n            const item = $(el);\n            const link = item.children('link').text() || item.children('guid').text();\n            const title = item.children('title').text();","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/lemonde/en.ts#L141-L177","documentation":"Thrown by the lemonde (Le Monde English) handler as a plain Error when the `category` path param is not a key in feedMap. feedMap maps slugs (international, economy, sports, opinion, etc., plus '' for the homepage) to RSS XML URLs. An unknown slug yields feedUrl=undefined, which the guard rejects before any fetch.","triggerScenarios":"Request to /lemonde/en/<slug> where <slug> is not in feedMap — e.g. /lemonde/en/world (wrong; should be 'international'), /lemonde/en/politique (French slug; English edition uses 'politics'), or a typo. Omitting the category is safe (defaults to '' = homepage).","commonSituations":"User uses a French-edition or Le Monde.fr slug instead of the English-edition one; typo; trailing slash creating an empty-but-present segment; slug was removed from Le Monde's RSS offering.","solutions":["Use a slug from the route description table (e.g. international, economy, sports, opinion)","Omit the segment to get the homepage feed","If Le Monde added a new RSS feed, add the slug→URL mapping to feedMap in lib/routes/lemonde/en.ts:10-72","Watch for hyphenated slugs (asia-pacific, united-states) — exact match required"],"exampleFix":"// before\nconst feedUrl = feedMap[category];\nif (!feedUrl) {\n    throw new Error(`Invalid category: ${category}`);\n}\n// after — list valid keys on failure\nconst feedUrl = feedMap[category];\nif (!feedUrl) {\n    const valid = Object.keys(feedMap).map((k) => k || '(empty)').join(', ');\n    throw new Error(`Invalid category '${category}'. Valid: ${valid}`);\n}","handlingStrategy":"type-guard","validationCode":"const FEED_MAP_KEYS = new Set(Object.keys(feedMap));\nfunction isValidLeMondeCategory(cat: string): boolean {\n  return FEED_MAP_KEYS.has(cat);\n}\nif (!isValidLeMondeCategory(ctx.req.param('category') ?? '')) {\n  return ctx.json({ error: `invalid category`, allowed: [...FEED_MAP_KEYS] }, 400);\n}","typeGuard":"function isLeMondeCategory(v: unknown): v is keyof typeof feedMap {\n  return typeof v === 'string' && v in feedMap;\n}","tryCatchPattern":"try { return await handler(ctx); }\ncatch (e) {\n  if (e instanceof Error && /Invalid category/.test(e.message)) {\n    return ctx.json({ error: e.message, valid: Object.keys(feedMap) }, 400);\n  }\n  throw e;\n}","preventionTips":["Derive the valid-keys set from feedMap so it stays in sync","Omit the category param to safely get the homepage feed","Watch for hyphenated and French-vs-English slug mismatches","Sync the route description table when Le Monde adds/removes RSS feeds"],"tags":["validation","parameter","catalog","rss"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}