{"record":{"id":"f8317c8068013544","repo":"DIYgod/RSSHub","slug":"invalid-youtube-channel-id-nyou-may-want-to-use","errorCode":null,"errorMessage":"Invalid YouTube channel ID. \\nYou may want to use <code>/youtube/user/:id</code> instead.","messagePattern":"Invalid YouTube channel ID\\. \\\\nYou may want to use <code>/youtube/user/:id</code> instead\\.","errorType":"validation","errorClass":"InvalidParameterError","httpStatus":503,"severity":"error","filePath":"lib/routes/youtube/channel.ts","lineNumber":68,"sourceCode":"    },\n};\n\nasync function handler(ctx) {\n    const id = ctx.req.param('id');\n\n    // Parse route parameters\n    const routeParams = ctx.req.param('routeParams');\n    const params = new URLSearchParams(routeParams);\n\n    // Get embed parameter\n    const embed = !params.get('embed');\n\n    // Get filterShorts parameter (default to true if not specified)\n    const filterShortsStr = params.get('filterShorts');\n    const filterShorts = [null, '', 'true'].includes(filterShortsStr);\n\n    if (!isYouTubeChannelId(id)) {\n        throw new InvalidParameterError('Invalid YouTube channel ID. \\nYou may want to use <code>/youtube/user/:id</code> instead.');\n    }\n\n    const isJsonFeed = ctx.req.query('format') === 'json';\n\n    const data = await callApi({\n        googleApi: getDataByChannelIdGoogle,\n        youtubeiApi: getDataByChannelIdYoutubei,\n        params: { channelId: id, embed, filterShorts, isJsonFeed },\n    });\n\n    return data;\n}\n","sourceCodeStart":50,"sourceCodeEnd":81,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/youtube/channel.ts#L50-L81","documentation":"InvalidParameterError thrown by the YouTube channel handler when the :id segment fails isYouTubeChannelId, which tests the regex /^UC[\\w-]{21}[AQgw]$/ (24 chars: 'UC' + 22 word/dash chars ending in A/Q/g/w). The message nudges users toward /youtube/user/:id, because a non-conforming id usually means the caller supplied a username or @handle instead of a canonical channel id.","triggerScenarios":"A request to /youtube/channel/:id where id is a username (e.g. 'DIYgod'), an @handle ('@SomeHandle'), a custom URL ('c/...' slug), or a malformed/garbled channel id. The regex rejects all of these before any API call.","commonSituations":"Caller confused channel id with username/handle/custom URL; copied the wrong segment from a YouTube URL (e.g. used the /c/ slug); trailing/leading whitespace or URL-encoded characters in the segment.","solutions":["Provide a canonical UC... channel id (find it via the channel page source or the find-your-channel-id tool).","If you only have a username, use /youtube/user/:username.","If you have an @handle, use /youtube/user/@handle.","If you have a custom URL (youtube.com/c/slug), use /youtube/c/:slug."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const CHANNEL_ID_RE = /^UC[\\w-]{21}[AQgw]$/;\nfunction requireChannelId(id: string) {\n    if (!CHANNEL_ID_RE.test(id)) {\n        throw new InvalidParameterError(`\"${id}\" is not a UC... channel id. Use /youtube/user/:id for usernames/handles or /youtube/c/:slug for custom URLs.`);\n    }\n}","typeGuard":"function isYouTubeChannelId(id: string): boolean {\n    return /^UC[\\w-]{21}[AQgw]$/.test(id);\n}","tryCatchPattern":null,"preventionTips":["Distinguish channel id (UC...) from username, @handle, and custom-URL slug.","Use the matching route: /channel/:id, /user/:username, /user/@handle, or /c/:slug.","Copy the channel id from the channel page's source or the find-your-id tool, not from the /c/ URL."],"tags":["youtube","validation","channel-id","route-param"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}