{"record":{"id":"e8079f5966f028e4","repo":"Panniantong/Agent-Reach","slug":"profile-scrub-url-credentials-profile-not-fou","errorCode":null,"errorMessage":"Profile '{scrub_url_credentials(profile)}' not found for {scrub_url_credentials(browser)}.{hint}","messagePattern":"Profile '(.+?)' not found for (.+?)\\.(.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent_reach/cookie_extract.py","lineNumber":175,"sourceCode":"def _profile_cookie_file(browser: str, profile: str) -> str:\n    \"\"\"Resolve an explicit profile or fail without falling back to Default.\"\"\"\n    if browser not in PROFILE_SELECTABLE_BROWSERS:\n        raise ValueError(\n            \"Profile selection is supported only for \"\n            f\"{', '.join(PROFILE_SELECTABLE_BROWSERS)}, \"\n            f\"not {scrub_url_credentials(browser)}.\"\n        )\n\n    profiles = list_browser_profiles(browser)\n    for candidate in profiles:\n        if candidate[\"folder\"] == profile:\n            return candidate[\"cookies_path\"]\n\n    available = \", \".join(\n        scrub_url_credentials(item[\"folder\"]) for item in profiles\n    )\n    hint = f\" Available profiles: {available}.\" if available else \"\"\n    raise ValueError(\n        f\"Profile '{scrub_url_credentials(profile)}' not found for \"\n        f\"{scrub_url_credentials(browser)}.{hint}\"\n    )\n\n\ndef _platform_spec(platform: Optional[str]) -> PlatformSpec:\n    \"\"\"Return the one explicitly requested platform specification.\"\"\"\n    if not platform:\n        raise ValueError(\n            \"platform is required for browser-cookie extraction; \"\n            f\"choose one of: {', '.join(_PLATFORM_SPECS_BY_KEY)}\"\n        )\n    key = platform.lower()\n    try:\n        return _PLATFORM_SPECS_BY_KEY[key]\n    except KeyError as exc:\n        raise ValueError(\n            f\"Unsupported platform: {scrub_url_credentials(platform)}. \"","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/Panniantong/Agent-Reach/blob/93ae1d18c37b707dec053c7c4f9d91cd8ef8943d/agent_reach/cookie_extract.py#L157-L193","documentation":"Raised by _profile_cookie_file() in agent_reach/cookie_extract.py when the requested profile folder name does not exist in the browser's User Data directory. The code iterates list_browser_profiles(browser) and matches candidate['folder'] exactly; on miss it raises with a hint enumerating the available folder names (e.g. 'Default', 'Profile 1').","triggerScenarios":"Calling extract_all(browser='chrome', platform='xueqiu', profile='Profile 2') when Chrome only has 'Default' and 'Profile 1'; passing a display name ('Work') instead of the folder name; quoting or case mismatches.","commonSituations":"Hardcoding a profile name that exists on the dev machine but not on the target; the browser was reset and profile folders were renumbered; using the human-visible profile label rather than the on-disk folder.","solutions":["Read the hint in the error message — it lists the exact available folder names","Enumerate profiles programmatically with list_browser_profiles(browser) and pick from the returned 'folder' values","Verify the browser has actually created multiple profiles (chrome://settings) before requesting one"],"exampleFix":"# before\nextract_all(browser='chrome', platform='bilibili', profile='Profile 2')\n\n# after\nfrom agent_reach.cookie_extract import list_browser_profiles\nprofiles = {p['folder'] for p in list_browser_profiles('chrome')}\nprofile = 'Profile 1' if 'Profile 1' in profiles else 'Default'\nextract_all(browser='chrome', platform='bilibili', profile=profile)","handlingStrategy":"validation","validationCode":"from agent_reach.cookie_extract import list_browser_profiles\nfolders = {p['folder'] for p in list_browser_profiles(browser)}\nif profile not in folders:\n    profile = sorted(folders)[0]  # or prompt the user","typeGuard":"def valid_profile(browser: str, profile: str) -> bool:\n    try:\n        return any(p['folder'] == profile for p in list_browser_profiles(browser))\n    except Exception:\n        return False","tryCatchPattern":"try:\n    extract_all(browser='chrome', platform='bilibili', profile=prof)\nexcept ValueError as e:\n    if 'not found for' in str(e):\n        prof = list_browser_profiles('chrome')[0]['folder']\n    else:\n        raise","preventionTips":["Always source folder names from list_browser_profiles, never hardcode","Use the on-disk 'Profile N' name, not the browser UI label","Parse the 'Available profiles:' hint from the message when recovering"],"tags":["cookies","browser","profile","validation"],"backgroundTag":null,"analyzedSha":"93ae1d18c37b707dec053c7c4f9d91cd8ef8943d","analyzedAt":"2026-08-14T22:54:06.735Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}