ytdl-org/youtube-dl · error · ValueError

Invalid syntax in Cookie Header

Error message

Invalid syntax in Cookie Header

What it means

The AVM2 'getproperty' opcode (and related property reads) in swfinterp ends in a catch-all: if the (name, object) combination is not one of the explicitly handled pairs (string indexes, array slice/join, scope dicts, etc.), it raises NotImplementedError('Unsupported property %r on %r'). It signals that the interpreted ActionScript reads a property youtube-dl's interpreter never modeled.

Source

Thrown at youtube_dl/YoutubeDL.py:926

        """
        return dict(filter(lambda pair: pair[0].lower() != 'cookie', (http_headers or {}).items()))

    def _load_cookies(self, data, **kwargs):
        """Loads cookies from a `Cookie` header

        This tries to work around the security vulnerability of passing cookies to every domain.

        @param data         The Cookie header as a string to load the cookies from
        @param autoscope    If `False`, scope cookies using Set-Cookie syntax and error for cookie without domains
                            If `True`, save cookies for later to be stored in the jar with a limited scope
                            If a URL, save cookies in the jar with the domain of the URL
        """
        # autoscope=True (kw-only)
        autoscope = kwargs.get('autoscope', True)

        for cookie in compat_http_cookies_SimpleCookie(data).values() if data else []:
            if autoscope and any(cookie.values()):
                raise ValueError('Invalid syntax in Cookie Header')

            domain = cookie.get('domain') or ''
            expiry = cookie.get('expires')
            if expiry == '':  # 0 is valid so we check for `''` explicitly
                expiry = None
            prepared_cookie = compat_http_cookiejar_Cookie(
                cookie.get('version') or 0, cookie.key, cookie.value, None, False,
                domain, True, True, cookie.get('path') or '', bool(cookie.get('path')),
                bool(cookie.get('secure')), expiry, False, None, None, {})

            if domain:
                self.cookiejar.set_cookie(prepared_cookie)
            elif autoscope is True:
                self.report_warning(
                    'Passing cookies as a header is a potential security risk; '
                    'they will be scoped to the domain of the downloaded urls. '
                    'Please consider loading cookies from a file or browser instead.',
                    only_once=True)

View on GitHub (pinned to 956b8c5855)

Solutions

  1. Read the exception's (mname, obj) pair and add an elif branch for it just above the raise in swfinterp.py — the surrounding code shows the pattern (compute res, stack.append(res), continue).
  2. If the property read belongs to a method you can reimplement, patch_function it in Python instead of extending the interpreter.
  3. Update to the latest youtube-dl / yt-dlp; newly needed properties for big sites get added quickly.
  4. If interpretation is optional for your flow, catch NotImplementedError and fall back to a non-interpreted extraction path.

Example fix

# before (swfinterp.py, getproperty fallthrough)
raise NotImplementedError(
    'Unsupported property %r on %r' % (mname, obj))

# after
elif mname == 'charAt' and isinstance(obj, compat_str):
    assert len(args) == 1
    stack.append(obj[args[0]])
    continue
else:
    raise NotImplementedError(
        'Unsupported property %r on %r' % (mname, obj))
Defensive patterns

Strategy: fallback

Try / catch

try:
    out = func(args)
except NotImplementedError as e:
    if 'Unsupported property' in str(e):
        # e.args carries (mname, obj) — add an elif branch for it or patch caller
        mname, obj = e.args[0].split(' on ', 1)
        raise ExtractorError('interpreter gap: property %s on %s' % (mname, obj))
    raise

Prevention

When it happens

Trigger: Interpreted bytecode executes getproperty where obj is an unhandled type (e.g. a dictionary/namespace object, a _AVMClass_Obj without that member, a Number/Boolean) or mname is an unhandled builtin (length on an unhandled container, charAt, push, etc. — only a handful are special-cased above the raise).

Common situations: Player SWF rotation introduces new property reads in the deciphering path; extractor authors prototyping with swfinterp hit gaps immediately; errors mention the exact property and object, which is the key debugging clue.

Related errors


AI-assisted analysis of ytdl-org/youtube-dl@956b8c5855 (2026-08-14). Data as JSON: /api/errors/b4c4668f36aae165. Report an issue: GitHub.