{"record":{"id":"5ea64cf78c2ba509","repo":"yt-dlp/yt-dlp","slug":"invalid-cookies-from-browser-arguments-opts-cook","errorCode":null,"errorMessage":"invalid cookies from browser arguments: {opts.cookiesfrombrowser}","messagePattern":"invalid cookies from browser arguments: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"yt_dlp/__init__.py","lineNumber":404,"sourceCode":"                    raise ValueError(f'invalid {name} time range \"{regex}\". {err}')\n                ranges.append(dur)\n\n        return chapters, ranges, from_url\n\n    opts.remove_chapters, opts.remove_ranges, _ = parse_chapters('--remove-chapters', opts.remove_chapters)\n    opts.download_ranges = download_range_func(*parse_chapters('--download-sections', opts.download_ranges, True))\n\n    # Cookies from browser\n    if opts.cookiesfrombrowser:\n        container = None\n        mobj = re.fullmatch(r'''(?x)\n            (?P<name>[^+:]+)\n            (?:\\s*\\+\\s*(?P<keyring>[^:]+))?\n            (?:\\s*:\\s*(?!:)(?P<profile>.+?))?\n            (?:\\s*::\\s*(?P<container>.+))?\n        ''', opts.cookiesfrombrowser)\n        if mobj is None:\n            raise ValueError(f'invalid cookies from browser arguments: {opts.cookiesfrombrowser}')\n        browser_name, keyring, profile, container = mobj.group('name', 'keyring', 'profile', 'container')\n        browser_name = browser_name.lower()\n        if browser_name not in SUPPORTED_BROWSERS:\n            raise ValueError(f'unsupported browser specified for cookies: \"{browser_name}\". '\n                             f'Supported browsers are: {\", \".join(sorted(SUPPORTED_BROWSERS))}')\n        if keyring is not None:\n            keyring = keyring.upper()\n            if keyring not in SUPPORTED_KEYRINGS:\n                raise ValueError(f'unsupported keyring specified for cookies: \"{keyring}\". '\n                                 f'Supported keyrings are: {\", \".join(sorted(SUPPORTED_KEYRINGS))}')\n        opts.cookiesfrombrowser = (browser_name, profile, keyring, container)\n\n    if opts.impersonate is not None:\n        opts.impersonate = ImpersonateTarget.from_str(opts.impersonate.lower())\n\n    # MetadataParser\n    def metadataparser_actions(f):\n        if isinstance(f, str):","sourceCodeStart":386,"sourceCodeEnd":422,"githubUrl":"https://github.com/yt-dlp/yt-dlp/blob/81ecd58b1394793e6da9998cc19fdb45657f1685/yt_dlp/__init__.py#L386-L422","documentation":"Raised while parsing --cookies-from-browser: the argument must fullmatch 'NAME[+KEYRING][:PROFILE][::CONTAINER]' where NAME excludes '+' and ':' (regex: name [^+:]+, optional '+keyring' [^:]+, optional ':profile' that may not itself start with ':', optional '::container'). If re.fullmatch returns None, this ValueError echoes the raw argument. On success the value is rewritten to a (browser, profile, keyring, container) tuple.","triggerScenarios":"--cookies-from-browser 'chrome:' (trailing colon with nothing after it); ':profile' (empty browser name); 'chrome+' (empty keyring); 'chrome:::x' (extra colons); browser names containing '+' such as 'chromium+beta'. Note 'chrome::Default' is valid — the double-colon form is the container slot.","commonSituations":"Confusing the one-colon (profile) and two-colon (container) separators; trailing separators from shell variable expansion (${BROWSER}: with empty profile); passing URLs or paths instead of a browser spec.","solutions":["Use the documented shape: BROWSER[+KEYRING][:PROFILE][::CONTAINER], e.g. 'chrome', 'firefox:default-release', 'chrome+kwallet5', 'chrome::Personal'.","Remove trailing/leading separators; every separator must be followed by content.","Quote the whole argument so shell spaces in profile names survive, e.g. --cookies-from-browser 'chrome::Profile 1'.","Remember the first colon switches to PROFILE and '::' switches to CONTAINER — do not use '::' for profiles."],"exampleFix":"# before\nyt-dlp --cookies-from-browser 'chrome:' URL\n# ValueError: invalid cookies from browser arguments: chrome:\n\n# after\nyt-dlp --cookies-from-browser 'chrome::Default' URL   # BROWSER[+KEYRING][:PROFILE][::CONTAINER]","handlingStrategy":"validation","validationCode":"import re\n\nBROWSER_SPEC_RE = re.compile(r'(?x)(?P<name>[^+:]+)(?:\\s*\\+\\s*(?P<keyring>[^:]+))?(?:\\s*:\\s*(?!:)(?P<profile>.+?))?(?:\\s*::\\s*(?P<container>.+))?')\n\ndef parse_spec(spec):\n    m = BROWSER_SPEC_RE.fullmatch(spec)\n    if m is None:\n        raise ValueError(f'invalid cookies from browser arguments: {spec}')\n    return m.group('name', 'keyring', 'profile', 'container')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["One colon = PROFILE, double colon = CONTAINER; '+' = KEYRING.","Every separator must be followed by content — no trailing ':' or '+'.","Quote the whole argument to protect spaces in profile names.","Validate the spec with the same regex before shelling out from scripts."],"tags":["cli","cookies","browser","validation","argument-parsing"],"backgroundTag":"cookies-from-browser-misconfigured","analyzedSha":"81ecd58b1394793e6da9998cc19fdb45657f1685","analyzedAt":"2026-08-22T12:21:25.439Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}