{"record":{"id":"632bea63a80d3878","repo":"yt-dlp/yt-dlp","slug":"invalid-name-value-given","errorCode":null,"errorMessage":"invalid {name} \"{value}\" given","messagePattern":"invalid (.+?) \"(.+?)\" given","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"yt_dlp/__init__.py","lineNumber":189,"sourceCode":"        else:\n            _unused_compat_opt('mtime-by-default')\n\n    _video_multistreams_set = set_default_compat('multistreams', 'allow_multiple_video_streams', False, remove_compat=False)\n    _audio_multistreams_set = set_default_compat('multistreams', 'allow_multiple_audio_streams', False, remove_compat=False)\n    if _video_multistreams_set is False and _audio_multistreams_set is False:\n        _unused_compat_opt('multistreams')\n    if 'filename' in opts.compat_opts:\n        if opts.outtmpl.get('default') is None:\n            opts.outtmpl.update({'default': '%(title)s-%(id)s.%(ext)s'})\n        else:\n            _unused_compat_opt('filename')\n\n\ndef validate_options(opts):\n    def validate(cndn, name, value=None, msg=None):\n        if cndn:\n            return True\n        raise ValueError((msg or 'invalid {name} \"{value}\" given').format(name=name, value=value))\n\n    def validate_in(name, value, items, msg=None):\n        return validate(value is None or value in items, name, value, msg)\n\n    def validate_regex(name, value, regex):\n        return validate(value is None or re.match(regex, value), name, value)\n\n    def validate_positive(name, value, strict=False):\n        return validate(value is None or value > 0 or (not strict and value == 0),\n                        name, value, '{name} \"{value}\" must be positive' + ('' if strict else ' or 0'))\n\n    def validate_minmax(min_val, max_val, min_name, max_name=None):\n        if max_val is None or min_val is None or max_val >= min_val:\n            return\n        if not max_name:\n            min_name, max_name = f'min {min_name}', f'max {min_name}'\n        raise ValueError(f'{max_name} \"{max_val}\" must be must be greater than or equal to {min_name} \"{min_val}\"')\n","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/yt-dlp/yt-dlp/blob/81ecd58b1394793e6da9998cc19fdb45657f1685/yt_dlp/__init__.py#L171-L207","documentation":"Default failure message of the validate() helper inside validate_options (yt_dlp/__init__.py). Any option check that fails without a custom message raises ValueError('invalid {name} \"{value}\" given'), where name is the human-readable option name (e.g. 'rate limit', 'buffer size'). Typical producers are validate_bytes (parse_bytes returned None for strings like \"10Mbps\") and validate_in/validate_regex fallbacks. The CLI catches this ValueError and aborts with a usage error before any download starts.","triggerScenarios":"Passing a non-numeric byte-size to --limit-rate, --min-filesize, --max-filesize, --buffer-size, or --http-chunk-size (parse_bytes must return a number; suffixes k/M/G/T/P/E/Z/Y and optional 'B'/'iB' are accepted); or an option value failing validate_in/validate_regex without a dedicated message. Programmatically: calling yt_dlp.validate_options(opts) on a hand-built opts object.","commonSituations":"Typing --limit-rate 10Mbps instead of 10M; --max-filesize 1GBs; passing empty strings or negative sizes; scripts assembling opts objects with unvalidated strings from config files or web forms.","solutions":["Read the option name in the message and fix that exact value; sizes must be a plain number optionally followed by a unit like 10, 10M, 10MiB, 1.5G.","Check the option's accepted syntax with yt-dlp --help.","If the value comes from user input or config, validate it with yt_dlp.utils.parse_bytes (must not be None) before passing it on.","For programmatic opts, run yt_dlp.validate_options(opts) early so you get these errors at startup with your own handling."],"exampleFix":"# before\nydl_opts = {'ratelimit': '10Mbps'}  # ValueError: invalid rate limit \"10Mbps\" given\n# after\nydl_opts = {'ratelimit': '10M'}","handlingStrategy":"validation","validationCode":"from yt_dlp.utils import parse_bytes\n\nfor key in ('ratelimit', 'min_filesize', 'max_filesize', 'buffersize', 'http_chunk_size'):\n    val = ydl_opts.get(key)\n    if val is not None and parse_bytes(val) is None:\n        raise SystemExit(f'invalid {key.replace(\"_\", \" \")} \"{val}\" given')","typeGuard":null,"tryCatchPattern":"from yt_dlp import parse_options, validate_options\ntry:\n    opts, urls = parse_options()\n    validate_options(opts)\nexcept ValueError as err:\n    raise SystemExit(f'bad yt-dlp options: {err}')","preventionTips":["Write byte sizes as number+unit only (10, 10M, 10MiB, 1.5G).","Validate config-file values with parse_bytes before building YoutubeDL.","Run yt_dlp.validate_options(opts) in wrappers that assemble opts programmatically.","Check the option name printed in the message — it pinpoints the bad value."],"tags":["cli","options","validation","value-error"],"backgroundTag":"option-validation-failed","analyzedSha":"81ecd58b1394793e6da9998cc19fdb45657f1685","analyzedAt":"2026-08-22T12:21:25.439Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}