Panniantong/Agent-Reach · error · ValueError

Profile selection is supported only for {', '.join(PROFILE_S

Error message

Profile selection is supported only for {', '.join(PROFILE_SELECTABLE_BROWSERS)}, not {scrub_url_credentials(browser)}.

What it means

Raised by _profile_cookie_file() in agent_reach/cookie_extract.py when a profile= argument is passed for a browser that does not support explicit profile selection. PROFILE_SELECTABLE_BROWSERS is ('chrome', 'edge', 'brave') — only Chromium browsers with numbered 'Profile N' folders under a User Data directory. Firefox ('firefox') and 'opera' are rejected because profile resolution is only implemented against the Chromium layout.

Source

Thrown at agent_reach/cookie_extract.py:160

                    "folder": profile_dir.name,
                    "cookies_path": str(cookie_file),
                }
            )

    def sort_key(item):
        folder = item["folder"]
        suffix = folder.rsplit(" ", 1)[-1]
        number = int(suffix) if suffix.isdigit() else 0
        return (folder != "Default", number, folder)

    profiles.sort(key=sort_key)
    return profiles


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}"
    )

View on GitHub (pinned to 93ae1d18c3)

Solutions

  1. Use browser='chrome', 'edge', or 'brave' when you need profile selection
  2. Drop the profile argument for firefox/opera and let rookiepy use the default profile
  3. List valid folders first with list_browser_profiles(browser) to see what a supported browser exposes

Example fix

# before
extract_all(browser='firefox', platform='bilibili', profile='release')  # ValueError

# after
extract_all(browser='chrome', platform='bilibili', profile='Profile 1')
Defensive patterns

Strategy: validation

Validate before calling

from agent_reach.cookie_extract import PROFILE_SELECTABLE_BROWSERS
if profile is not None and browser.lower() not in PROFILE_SELECTABLE_BROWSERS:
    raise ValueError(f'profile selection unsupported for {browser}')

Type guard

def supports_profile(browser: str) -> bool:
    return browser.lower() in ('chrome', 'edge', 'brave')

Try / catch

try:
    extract_all(browser=b, platform=p, profile=prof)
except ValueError as e:
    if 'Profile selection' in str(e):
        prof = None  # retry without profile on a default-profile browser
    else:
        raise

Prevention

When it happens

Trigger: Calling extract_all(browser='firefox', platform='bilibili', profile='default-release') or browser='opera' with any non-None profile.

Common situations: Assuming every browser in SUPPORTED_BROWSERS (chrome, firefox, edge, brave, opera) also accepts profile=; porting a Firefox multi-profile workflow to this API; passing profile='Default' unconditionally for all browsers.

Related errors


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