{"record":{"id":"da73de4bcf3f3462","repo":"Panniantong/Agent-Reach","slug":"cookie-extraction-profile-hint-requires-browser-c","errorCode":null,"errorMessage":"Cookie extraction{profile_hint} requires browser_cookie3 (or rookiepy when no profile is selected).\nInstall: pip install browser-cookie3","messagePattern":"Cookie extraction(.+?) requires browser_cookie3 \\(or rookiepy when no profile is selected\\)\\.\nInstall: pip install browser-cookie3","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"agent_reach/cookie_extract.py","lineNumber":256,"sourceCode":"\n    # Try rookiepy first (Rust-based, more stable), fallback to browser_cookie3\n    use_rookiepy = False\n    if cookie_file is None:\n        try:\n            import rookiepy\n            use_rookiepy = True\n        except ImportError:\n            pass\n    if not use_rookiepy:\n        try:\n            import browser_cookie3\n        except ImportError:\n            profile_hint = (\n                f\" for profile '{scrub_url_credentials(profile)}'\"\n                if profile is not None\n                else \"\"\n            )\n            raise RuntimeError(\n                f\"Cookie extraction{profile_hint} requires browser_cookie3\"\n                \" (or rookiepy when no profile is selected).\\n\"\n                \"Install: pip install browser-cookie3\"\n            )\n\n    if use_rookiepy:\n        # 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:","sourceCodeStart":238,"sourceCodeEnd":274,"githubUrl":"https://github.com/Panniantong/Agent-Reach/blob/93ae1d18c37b707dec053c7c4f9d91cd8ef8943d/agent_reach/cookie_extract.py#L238-L274","documentation":"Raised by extract_all() in agent_reach/cookie_extract.py when neither rookiepy nor browser_cookie3 can be imported. rookiepy is only attempted when no profile is selected (rookiepy cannot target a specific profile folder); otherwise the code needs browser_cookie3, and if that import fails the extraction cannot proceed.","triggerScenarios":"Calling extract_all() on a machine where neither package is installed, or extract_all(profile='Profile 1') where only rookiepy (at most) is available — the profile path forces browser_cookie3.","commonSituations":"Fresh install of agent-reach without the optional cookie extras; venv missing browser-cookie3; using profile= in an environment that only installed rookiepy.","solutions":["pip install browser-cookie3 (covers both the profile and no-profile paths)","If you do not need a profile, ensure rookiepy is installed so the rookiepy path is used","Verify with `python -c \"import browser_cookie3\"` inside the same venv agent-reach runs in"],"exampleFix":"# before: ModuleNotFoundError leads to RuntimeError at extract time\nextract_all(browser='chrome', platform='bilibili', profile='Profile 1')\n\n# after\npip install browser-cookie3\nextract_all(browser='chrome', platform='bilibili', profile='Profile 1')","handlingStrategy":"validation","validationCode":"def cookie_backend_available(profile: str | None) -> bool:\n    if profile is None:\n        try:\n            import rookiepy; return True\n        except ImportError:\n            pass\n    try:\n        import browser_cookie3; return True\n    except ImportError:\n        return False","typeGuard":"def can_extract(profile: str | None) -> bool:\n    return cookie_backend_available(profile)","tryCatchPattern":"try:\n    extract_all(browser=b, platform=p, profile=prof)\nexcept RuntimeError as e:\n    if 'browser_cookie3' in str(e):\n        subprocess.run([sys.executable, '-m', 'pip', 'install', 'browser-cookie3'])\n    else:\n        raise","preventionTips":["Ship browser-cookie3 in your deployment requirements when profiles are used","Check importability in doctor/startup diagnostics before extraction","Remember rookiepy cannot serve explicit profile= requests"],"tags":["cookies","dependency","installation"],"backgroundTag":null,"analyzedSha":"93ae1d18c37b707dec053c7c4f9d91cd8ef8943d","analyzedAt":"2026-08-14T22:54:06.735Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}