{"record":{"id":"9a64ca5320a6bec7","repo":"Panniantong/Agent-Reach","slug":"could-not-read-browser-cookies-via-rookiepy-sc","errorCode":null,"errorMessage":"Could not read {browser} cookies via rookiepy: {scrub_url_credentials(e)}\nMake sure {browser} is closed and you have permission.","messagePattern":"Could not read (.+?) cookies via rookiepy: (.+?)\nMake sure (.+?) is closed and you have permission\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"agent_reach/cookie_extract.py","lineNumber":281,"sourceCode":"        # rookiepy returns list of dicts with name/value/domain/path keys\n        try:\n            browser_funcs = {\n                \"chrome\": rookiepy.chrome,\n                \"firefox\": rookiepy.firefox,\n                \"edge\": rookiepy.edge,\n                \"brave\": rookiepy.brave,\n                \"opera\": rookiepy.opera,\n            }\n            raw_cookies = browser_funcs[browser](list(spec[\"domains\"]))\n            # Wrap into objects with .name, .value, .domain for compatibility\n            class _Cookie:\n                def __init__(self, d):\n                    self.name = d.get(\"name\", \"\")\n                    self.value = d.get(\"value\", \"\")\n                    self.domain = d.get(\"domain\", \"\")\n            cookie_jar = [_Cookie(c) for c in raw_cookies]\n        except Exception as e:\n            raise RuntimeError(\n                f\"Could not read {browser} cookies via rookiepy: \"\n                f\"{scrub_url_credentials(e)}\\n\"\n                f\"Make sure {browser} is closed and you have permission.\"\n            )\n    else:\n        browser_funcs = {\n            \"chrome\": browser_cookie3.chrome,\n            \"firefox\": browser_cookie3.firefox,\n            \"edge\": browser_cookie3.edge,\n            \"brave\": browser_cookie3.brave,\n            \"opera\": browser_cookie3.opera,\n        }\n        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:","sourceCodeStart":263,"sourceCodeEnd":299,"githubUrl":"https://github.com/Panniantong/Agent-Reach/blob/93ae1d18c37b707dec053c7c4f9d91cd8ef8943d/agent_reach/cookie_extract.py#L263-L299","documentation":"Raised by extract_all() in agent_reach/cookie_extract.py when the rookiepy backend throws while loading cookies for the requested browser. Any exception from browser_funcs[browser](domains) — locked SQLite cookie stores, permission errors, or rookiepy internals — is wrapped in this RuntimeError with the underlying message scrubbed of credentials. rookiepy is only used when no profile is selected.","triggerScenarios":"extract_all(browser='chrome', platform='xueqiu') while Chrome is running (cookie DB locked), on Linux with an encrypted keyring rookiepy cannot unlock, or when the browser has never created a cookie store.","commonSituations":"Running extraction with the browser open; headless CI boxes with no Chrome profile ever initialized; snap-packaged Chromium storing cookies where rookiepy does not look.","solutions":["Close the target browser completely (including background processes) and retry","Verify the browser has been used and has a cookie store on this machine","If it keeps failing, install browser-cookie3 and/or fall back to a manual Cookie-Editor export"],"exampleFix":"# before\ncookies = extract_all(browser='chrome', platform='bilibili')  # RuntimeError while Chrome open\n\n# after: ensure Chrome is closed first\nimport subprocess; subprocess.run(['pkill', '-f', 'Google Chrome'])\ncookies = extract_all(browser='chrome', platform='bilibili')","handlingStrategy":"retry","validationCode":"def browser_running(name: str) -> bool:\n    out = subprocess.run(['pgrep', '-fl', {'chrome': 'Chrome', 'edge': 'msedge', 'brave': 'brave', 'opera': 'opera'}[name]], capture_output=True)\n    return out.returncode == 0","typeGuard":null,"tryCatchPattern":"for attempt in range(2):\n    try:\n        cookies = extract_all(browser='chrome', platform='bilibili')\n        break\n    except RuntimeError as e:\n        if 'rookiepy' in str(e) and attempt == 0:\n            close_browser('chrome'); continue\n        raise","preventionTips":["Close the browser before extraction runs","Retry once after the user closes the browser rather than failing immediately","Surface the scrubbed backend message — it usually names the lock or permission cause"],"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"}