Panniantong/Agent-Reach · error · RuntimeError

Could not read {browser} cookies: {scrub_url_credentials(e)}

Error message

Could not read {browser} cookies: {scrub_url_credentials(e)}
Make sure {browser} is closed and you have permission.

What it means

Raised by extract_all() in agent_reach/cookie_extract.py when the browser_cookie3 backend throws while loading cookies (the else-branch used when rookiepy is unavailable or a profile cookie_file was passed). It wraps any exception from browser_funcs[browser](**kwargs) — including cookie_file= reads for an explicit profile — with the same close-the-browser guidance, scrubbing credentials from the chained message.

Source

Thrown at agent_reach/cookie_extract.py:312

        try:
            cookie_jar = []
            seen = set()
            for domain in spec["domains"]:
                kwargs = {"domain_name": domain}
                if cookie_file is not None:
                    kwargs["cookie_file"] = cookie_file
                for cookie in browser_funcs[browser](**kwargs):
                    identity = (
                        getattr(cookie, "name", ""),
                        getattr(cookie, "domain", ""),
                        getattr(cookie, "path", ""),
                        getattr(cookie, "value", ""),
                    )
                    if identity not in seen:
                        seen.add(identity)
                        cookie_jar.append(cookie)
        except Exception as e:
            raise RuntimeError(
                f"Could not read {browser} cookies: {scrub_url_credentials(e)}\n"
                f"Make sure {browser} is closed and you have permission."
            )

    results = {}

    platform_cookies = {}
    for cookie in cookie_jar:
        # Re-check returned cookies instead of trusting the backend filter.
        if not domain_matches(cookie.domain, *spec["domains"]):
            continue

        if cookie.name in needed_cookies:
            platform_cookies[cookie.name] = cookie.value

    if platform_cookies:
        results[spec["config_key"]] = platform_cookies

View on GitHub (pinned to 93ae1d18c3)

Solutions

  1. Fully exit the browser (check tray/background processes) and retry
  2. Confirm the profile folder from list_browser_profiles actually contains a readable Cookies file
  3. On persistent failure, export cookies manually with Cookie-Editor and configure via the CLI

Example fix

# before
extract_all(browser='edge', platform='xueqiu', profile='Profile 1')  # RuntimeError

# after: quit Edge first, then
extract_all(browser='edge', platform='xueqiu', profile='Profile 1')
Defensive patterns

Strategy: retry

Validate before calling

cookie_file = Path(profile_path) / 'Cookies'
if not cookie_file.exists():
    raise FileNotFoundError(f'no cookie store at {cookie_file}')

Try / catch

try:
    extract_all(browser='chrome', platform='bilibili', profile=prof)
except RuntimeError as e:
    if 'Make sure' in str(e):
        prompt_user_to_close_browser(); return extract_all(browser='chrome', platform='bilibili', profile=prof)
    raise

Prevention

When it happens

Trigger: extract_all(browser='chrome', profile='Profile 1', platform='bilibili') with Chrome running or the profile's Cookies file unreadable; firefox/edge/brave/opera reads failing due to locked stores or DPAPI/keyring decryption errors.

Common situations: Profile-targeted extraction while the browser is open; Linux Chrome using app-encrypted cookies; Windows where the cookie DB belongs to a different user account.

Related errors


AI-assisted analysis of Panniantong/Agent-Reach@93ae1d18c3 (2026-08-14). Data as JSON: /api/errors/4cd1272194800c6a. Report an issue: GitHub.