{"record":{"id":"77513c51fb70fe48","repo":"crewAIInc/crewAI","slug":"invalid-youtube-channel-url-channel-url","errorCode":null,"errorMessage":"Invalid YouTube channel URL: {channel_url}","messagePattern":"Invalid YouTube channel URL: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"lib/crewai-tools/src/crewai_tools/rag/loaders/youtube_channel_loader.py","lineNumber":44,"sourceCode":"        try:\n            from pytube import Channel  # type: ignore[import-untyped]\n        except ImportError as e:\n            raise ImportError(\n                \"YouTube channel support requires pytube. Install with: uv add pytube\"\n            ) from e\n\n        channel_url = source.source\n\n        if not any(\n            pattern in channel_url\n            for pattern in [\n                \"youtube.com/channel/\",\n                \"youtube.com/c/\",\n                \"youtube.com/@\",\n                \"youtube.com/user/\",\n            ]\n        ):\n            raise ValueError(f\"Invalid YouTube channel URL: {channel_url}\")\n\n        metadata: dict[str, Any] = {\n            \"source\": channel_url,\n            \"data_type\": \"youtube_channel\",\n        }\n\n        try:\n            channel = Channel(channel_url)\n\n            metadata[\"channel_name\"] = channel.channel_name\n            metadata[\"channel_id\"] = channel.channel_id\n\n            max_videos = kwargs.get(\"max_videos\", 10)\n            video_urls = list(channel.video_urls)[:max_videos]\n            metadata[\"num_videos_loaded\"] = len(video_urls)\n            metadata[\"total_videos\"] = len(list(channel.video_urls))\n\n            content_parts = [","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-tools/src/crewai_tools/rag/loaders/youtube_channel_loader.py#L26-L62","documentation":"ValueError from the YouTube channel loader's URL validation. It does simple substring matching: the URL must contain one of 'youtube.com/channel/', 'youtube.com/c/', 'youtube.com/@', or 'youtube.com/user/'. Anything else — including youtu.be links, plain watch URLs, or non-YouTube URLs — is rejected before any network call.","triggerScenarios":"Passing a single video URL (youtube.com/watch?v=... or youtu.be/...), a playlist URL, a shorts URL, or a handle URL missing the '@' prefix. Note the check is literal substring matching, so even youtube.com/watch triggers 'invalid' despite being a valid YouTube page, and https://m.youtube.com/@name works only because '@' appears anywhere in the string.","commonSituations":"Users assume any YouTube URL works and pass video links to the channel loader; mobile youtu.be share links; URLs with the handle spelled without @; region-specific domains like youtube.co.uk.","solutions":["Use a canonical channel URL form: https://www.youtube.com/@handle, /channel/UC..., /c/CustomName, or /user/LegacyName.","For single videos, use the YouTube video loader instead of the channel loader.","Before loading, validate the URL contains one of the four accepted substrings yourself and route to the correct loader.","If you only have a video ID or youtu.be link, expand it to the full watch URL first and use the video loader."],"exampleFix":"# before\nloader.load(SourceContent(path=\"https://youtu.be/abc123\"))  # rejected\n\n# after\nloader.load(SourceContent(path=\"https://www.youtube.com/@somechannel\"))","handlingStrategy":"validation","validationCode":"CHANNEL_MARKERS = (\"youtube.com/channel/\", \"youtube.com/c/\", \"youtube.com/@\", \"youtube.com/user/\")\n\ndef is_channel_url(url: str) -> bool:\n    return any(m in url for m in CHANNEL_MARKERS)","typeGuard":null,"tryCatchPattern":"try:\n    result = channel_loader.load(src)\nexcept ValueError as e:\n    if \"Invalid YouTube channel URL\" in str(e):\n        route_to_correct_loader(src)  # video loader for watch/youtu.be links\n    raise","preventionTips":["Route watch?v=/youtu.be links to the video loader and only channel-form URLs here.","Normalize to https://www.youtube.com/@handle before loading.","Reject playlist URLs explicitly — neither loader supports them."],"tags":["youtube","url-validation","rag"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}