{"record":{"id":"e5f2862636e99145","repo":"ytdl-org/youtube-dl","slug":"incomplete-youtube-id-s-url-s-looks-truncated","errorCode":null,"errorMessage":"Incomplete YouTube ID %s. URL %s looks truncated.","messagePattern":"Incomplete YouTube ID (.+?)\\. URL (.+?) looks truncated\\.","errorType":"exception","errorClass":"ExtractorError","httpStatus":null,"severity":"error","filePath":"youtube_dl/extractor/youtube.py","lineNumber":4495,"sourceCode":"            'like  youtube-dl '\n            '\"https://www.youtube.com/watch?feature=foo&v=BaW_jenozKc\" '\n            ' or simply  youtube-dl BaW_jenozKc  .',\n            expected=True)\n\n\nclass YoutubeTruncatedIDIE(InfoExtractor):\n    IE_NAME = 'youtube:truncated_id'\n    IE_DESC = False  # Do not list\n    _VALID_URL = r'https?://(?:www\\.)?youtube\\.com/watch\\?v=(?P<id>[0-9A-Za-z_-]{1,10})$'\n\n    _TESTS = [{\n        'url': 'https://www.youtube.com/watch?v=N_708QY7Ob',\n        'only_matching': True,\n    }]\n\n    def _real_extract(self, url):\n        video_id = self._match_id(url)\n        raise ExtractorError(\n            'Incomplete YouTube ID %s. URL %s looks truncated.' % (video_id, url),\n            expected=True)\n","sourceCodeStart":4477,"sourceCodeEnd":4498,"githubUrl":"https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/youtube.py#L4477-L4498","documentation":"Raised by YoutubeTruncatedIDIE, a catch-all extractor whose _VALID_URL only matches youtube.com/watch?v=<id> URLs where the video id is 1-10 characters. Real YouTube ids are exactly 11 characters, so this extractor only fires when the generic YouTube extractor (which requires 11 chars) did not match. The error is marked expected=True, so youtube-dl reports it as a clean user-facing failure rather than a bug.","triggerScenarios":"Calling youtube-dl with a URL like 'https://www.youtube.com/watch?v=N_708QY7Ob' (id shorter than 11 chars). Typical causes: copy/paste cut the id off, a script truncated the URL, or a shell/environment variable holding the URL chopped the query string.","commonSituations":"URLs pasted into terminals where '&' splits the query string and only 'v=<partial>' survives; ids mangled by text editors or log truncation; feeding URLs from a file or playlist where lines were wrapped.","solutions":["Check the id in the 'v=' parameter: it must be exactly 11 characters from [0-9A-Za-z_-]; re-copy the full URL from the browser address bar","Quote the URL on the command line (single quotes) so '&' does not background the command and drop the query string","If the URL comes from a script or file, verify no line-wrapping/truncation happened before passing it to youtube-dl","Confirm the video still exists by opening the URL in a browser"],"exampleFix":"# before\nyoutube-dl https://www.youtube.com/watch?v=N_708QY7Ob\n# after (full 11-char id, quoted URL)\nyoutube-dl 'https://www.youtube.com/watch?v=N_708QY7ObE'","handlingStrategy":"validation","validationCode":"import re\n\ndef is_valid_youtube_watch_url(url):\n    m = re.match(r'^https?://(?:www\\.)?youtube\\.com/watch\\?v=([0-9A-Za-z_-]{11})$', url)\n    return m is not None\n\n# reject before invoking the downloader\nassert is_valid_youtube_watch_url(url), 'YouTube video id must be exactly 11 chars'","typeGuard":null,"tryCatchPattern":"try:\n    ydl.download([url])\nexcept ExtractorError as e:\n    if 'Incomplete YouTube ID' in str(e):\n        log.warning('URL truncated, re-check source: %s', url)  # expected, do not retry\n    else:\n        raise","preventionTips":["Always quote YouTube URLs on the command line so '&' does not truncate the query string","When generating URLs programmatically, assert the v parameter is exactly 11 characters","Treat this expected error as bad input data: fix the URL, never retry it unchanged"],"tags":["youtube","url-validation","user-input","extractor"],"backgroundTag":null,"analyzedSha":"956b8c585591b401a543e409accb163eeaaa1193","analyzedAt":"2026-08-14T18:59:47.863Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}