{"record":{"id":"97fe0a25acb6e5e5","repo":"DIYgod/RSSHub","slug":"invalid-channel-format-missing-id","errorCode":null,"errorMessage":"Invalid channel format. Missing -id","messagePattern":"Invalid channel format\\. Missing -id","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"lib/routes/castbox/channel.ts","lineNumber":56,"sourceCode":"        supportScihub: false,\n    },\n    radar: [\n        {\n            source: ['castbox.fm/channel/:channel'],\n            target: '/channel/:channel',\n        },\n    ],\n    name: 'Channels',\n    description: `Get the channel from the Castbox channel URL. For example, the URL of the channel \"Lemonade Stand\" is \\`https://castbox.fm/channel/Lemonade-Stand-id6776228\\`, where \\`Lemonade-Stand-id6776228\\` is the \\`channel\\` parameter.\n\nYou can use the RSSHub global \\`limit\\` query parameter to specify the maximum number of episodes to fetch from the Castbox API (defaults to 50). For example: \\`/castbox/channel/Lemonade-Stand-id6776228?limit=100\\`.`,\n    maintainers: ['ananyatimalsina'],\n    handler: async (ctx) => {\n        const { channel } = ctx.req.param();\n        const cid = channel.split('-id', 2)[1];\n\n        if (!cid) {\n            throw new Error('Invalid channel format. Missing -id');\n        }\n\n        const channelParams = { cid, r: 1, raw: 1, web: 1 };\n        const { m: cm, n: cn, queryStr: cQuery } = getNonce(channelParams);\n\n        const channelData = await ofetch(`https://everest.castbox.fm/data/channel/v3?${cQuery}&m=${cm}&n=${cn}`);\n\n        if (!channelData?.data) {\n            throw new Error('Failed to fetch channel data from Castbox');\n        }\n\n        const chData = channelData.data;\n        const limit = ctx.req.query('limit') ? Number(ctx.req.query('limit') as string) : 50;\n\n        const epParams = { cid, limit, r: 1, raw: 1, web: 1 };\n        const { m: em, n: en, queryStr: eQuery } = getNonce(epParams);\n\n        const epData = await ofetch(`https://everest.castbox.fm/data/episode_list/v2?${eQuery}&m=${em}&n=${en}`);","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/castbox/channel.ts#L38-L74","documentation":"Thrown by the Castbox channel route when the `channel` parameter does not contain the `-id` delimiter or has nothing after it. The handler splits on '-id' with limit 2 and reads index [1]; if the pattern is absent, index [1] is undefined and the guard trips. Plain `Error`, not `InvalidParameterError`.","triggerScenarios":"Supplying a channel slug without the `-id<digits>` suffix, e.g. `/castbox/channel/Lemonade-Stand`, or a slug ending exactly at `-id` with no trailing id (`...-id`).","commonSituations":"User copies only the human-readable slug portion of the URL and drops the `-id6776228` tail, or the source site changes its URL format.","solutions":["Pass the full channel identifier including the `-id<digits>` suffix, e.g. `/castbox/channel/Lemonade-Stand-id6776228`.","Copy the value verbatim from the castbox.fm channel URL path.","Maintainers: use `InvalidParameterError` and consider a stricter regex `/^(.+)-id(\\d+)$/` to also reject non-numeric ids."],"exampleFix":"// before\n/castbox/channel/Lemonade-Stand\n// after\n/castbox/channel/Lemonade-Stand-id6776228","handlingStrategy":"validation","validationCode":"function extractCastboxCid(channel: string): string | null {\n    const m = channel.match(/-id(\\d+)$/);\n    return m ? m[1] : null;\n}\nconst cid = extractCastboxCid(channel);\nif (!cid) {\n    throw new Error(`Channel '${channel}' is missing the -id<digits> suffix`);\n}","typeGuard":"function hasCastboxIdSuffix(channel: string): boolean {\n    return /-id\\d+$/.test(channel);\n}","tryCatchPattern":null,"preventionTips":["Always copy the channel identifier verbatim from the castbox.fm URL.","Maintainers: switch to a strict regex and `InvalidParameterError` for clearer 400 responses."],"tags":["validation","user-input","string-parsing","delimiter"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}