{"record":{"id":"4cd1272194800c6a","repo":"Panniantong/Agent-Reach","slug":"could-not-read-browser-cookies-scrub-url-crede","errorCode":null,"errorMessage":"Could not read {browser} cookies: {scrub_url_credentials(e)}\nMake sure {browser} is closed and you have permission.","messagePattern":"Could not read (.+?) cookies: (.+?)\nMake sure (.+?) is closed and you have permission\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"agent_reach/cookie_extract.py","lineNumber":312,"sourceCode":"        try:\n            cookie_jar = []\n            seen = set()\n            for domain in spec[\"domains\"]:\n                kwargs = {\"domain_name\": domain}\n                if cookie_file is not None:\n                    kwargs[\"cookie_file\"] = cookie_file\n                for cookie in browser_funcs[browser](**kwargs):\n                    identity = (\n                        getattr(cookie, \"name\", \"\"),\n                        getattr(cookie, \"domain\", \"\"),\n                        getattr(cookie, \"path\", \"\"),\n                        getattr(cookie, \"value\", \"\"),\n                    )\n                    if identity not in seen:\n                        seen.add(identity)\n                        cookie_jar.append(cookie)\n        except Exception as e:\n            raise RuntimeError(\n                f\"Could not read {browser} cookies: {scrub_url_credentials(e)}\\n\"\n                f\"Make sure {browser} is closed and you have permission.\"\n            )\n\n    results = {}\n\n    platform_cookies = {}\n    for cookie in cookie_jar:\n        # Re-check returned cookies instead of trusting the backend filter.\n        if not domain_matches(cookie.domain, *spec[\"domains\"]):\n            continue\n\n        if cookie.name in needed_cookies:\n            platform_cookies[cookie.name] = cookie.value\n\n    if platform_cookies:\n        results[spec[\"config_key\"]] = platform_cookies\n","sourceCodeStart":294,"sourceCodeEnd":330,"githubUrl":"https://github.com/Panniantong/Agent-Reach/blob/93ae1d18c37b707dec053c7c4f9d91cd8ef8943d/agent_reach/cookie_extract.py#L294-L330","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Fully exit the browser (check tray/background processes) and retry","Confirm the profile folder from list_browser_profiles actually contains a readable Cookies file","On persistent failure, export cookies manually with Cookie-Editor and configure via the CLI"],"exampleFix":"# before\nextract_all(browser='edge', platform='xueqiu', profile='Profile 1')  # RuntimeError\n\n# after: quit Edge first, then\nextract_all(browser='edge', platform='xueqiu', profile='Profile 1')","handlingStrategy":"retry","validationCode":"cookie_file = Path(profile_path) / 'Cookies'\nif not cookie_file.exists():\n    raise FileNotFoundError(f'no cookie store at {cookie_file}')","typeGuard":null,"tryCatchPattern":"try:\n    extract_all(browser='chrome', platform='bilibili', profile=prof)\nexcept RuntimeError as e:\n    if 'Make sure' in str(e):\n        prompt_user_to_close_browser(); return extract_all(browser='chrome', platform='bilibili', profile=prof)\n    raise","preventionTips":["Quit the browser fully (check background/tray processes) before profile extraction","Verify the profile's Cookies file exists via list_browser_profiles","Fall back to Cookie-Editor export when the store stays locked"],"tags":["cookies","browser","file-lock","runtime"],"backgroundTag":null,"analyzedSha":"93ae1d18c37b707dec053c7c4f9d91cd8ef8943d","analyzedAt":"2026-08-14T22:54:06.735Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}