Panniantong/Agent-Reach · error · ValueError

Profile '{scrub_url_credentials(profile)}' not found for {sc

Error message

Profile '{scrub_url_credentials(profile)}' not found for {scrub_url_credentials(browser)}.{hint}

What it means

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').

Source

Thrown at agent_reach/cookie_extract.py:175

def _profile_cookie_file(browser: str, profile: str) -> str:
    """Resolve an explicit profile or fail without falling back to Default."""
    if browser not in PROFILE_SELECTABLE_BROWSERS:
        raise ValueError(
            "Profile selection is supported only for "
            f"{', '.join(PROFILE_SELECTABLE_BROWSERS)}, "
            f"not {scrub_url_credentials(browser)}."
        )

    profiles = list_browser_profiles(browser)
    for candidate in profiles:
        if candidate["folder"] == profile:
            return candidate["cookies_path"]

    available = ", ".join(
        scrub_url_credentials(item["folder"]) for item in profiles
    )
    hint = f" Available profiles: {available}." if available else ""
    raise ValueError(
        f"Profile '{scrub_url_credentials(profile)}' not found for "
        f"{scrub_url_credentials(browser)}.{hint}"
    )


def _platform_spec(platform: Optional[str]) -> PlatformSpec:
    """Return the one explicitly requested platform specification."""
    if not platform:
        raise ValueError(
            "platform is required for browser-cookie extraction; "
            f"choose one of: {', '.join(_PLATFORM_SPECS_BY_KEY)}"
        )
    key = platform.lower()
    try:
        return _PLATFORM_SPECS_BY_KEY[key]
    except KeyError as exc:
        raise ValueError(
            f"Unsupported platform: {scrub_url_credentials(platform)}. "

View on GitHub (pinned to 93ae1d18c3)

Solutions

  1. Read the hint in the error message — it lists the exact available folder names
  2. Enumerate profiles programmatically with list_browser_profiles(browser) and pick from the returned 'folder' values
  3. Verify the browser has actually created multiple profiles (chrome://settings) before requesting one

Example fix

# before
extract_all(browser='chrome', platform='bilibili', profile='Profile 2')

# after
from agent_reach.cookie_extract import list_browser_profiles
profiles = {p['folder'] for p in list_browser_profiles('chrome')}
profile = 'Profile 1' if 'Profile 1' in profiles else 'Default'
extract_all(browser='chrome', platform='bilibili', profile=profile)
Defensive patterns

Strategy: validation

Validate before calling

from agent_reach.cookie_extract import list_browser_profiles
folders = {p['folder'] for p in list_browser_profiles(browser)}
if profile not in folders:
    profile = sorted(folders)[0]  # or prompt the user

Type guard

def valid_profile(browser: str, profile: str) -> bool:
    try:
        return any(p['folder'] == profile for p in list_browser_profiles(browser))
    except Exception:
        return False

Try / catch

try:
    extract_all(browser='chrome', platform='bilibili', profile=prof)
except ValueError as e:
    if 'not found for' in str(e):
        prof = list_browser_profiles('chrome')[0]['folder']
    else:
        raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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