crewAIInc/crewAI · error · SystemExit

Failed to retrieve organization list: {e!s}

Error message

Failed to retrieve organization list: {e!s}

What it means

Printed by `crewai org list` when the organizations API call returns an HTTP error status other than 401 (401 is handled separately as 'not logged in'). The message embeds the HTTPStatusError text (status code + URL) and the command exits 1. It means authentication succeeded but the Plus API rejected the request — 403/404/500 etc.

Source

Thrown at lib/cli/src/crewai_cli/organization/main.py:46

            table = Table(title="Your Organizations")
            table.add_column("Name", style="cyan")
            table.add_column("ID", style="green")
            for org in orgs:
                table.add_row(org["name"], org["uuid"])

            console.print(table)
        except HTTPStatusError as e:
            if e.response.status_code == 401:
                console.print(
                    "You are not logged in to any organization. Use 'crewai login' to login.",
                    style="bold red",
                )
                return
            console.print(
                f"Failed to retrieve organization list: {e!s}", style="bold red"
            )
            raise SystemExit(1) from e
        except Exception as e:
            console.print(
                f"Failed to retrieve organization list: {e!s}", style="bold red"
            )
            raise SystemExit(1) from e

    def switch(self, org_id: str) -> None:
        try:
            response = self.plus_api_client.get_organizations()
            response.raise_for_status()
            orgs = response.json()

            org = next((o for o in orgs if o["uuid"] == org_id), None)
            if not org:
                console.print(
                    f"Organization with id '{org_id}' not found.", style="bold red"
                )
                return

View on GitHub (pinned to 754d7323be)

Solutions

  1. Read the status code in the message: 403 → check your plan/entitlements on crewai.com; 5xx → retry later or check status page
  2. Update the CLI: uv tool upgrade crewai (or pip install -U crewai) to clear endpoint version skew
  3. Re-login (`crewai logout && crewai login`) to refresh tokens if the API reports auth-adjacent 403
  4. If persistent, capture `crewai org list` output and contact CrewAI support with the status code
Defensive patterns

Strategy: retry

Validate before calling

import httpx

def org_api_ok(client_base_url: str, headers: dict) -> bool:
    try:
        r = httpx.get(f"{client_base_url}/organizations", headers=headers, timeout=15)
        return r.status_code < 400 or r.status_code == 401
    except httpx.HTTPError:
        return False

Try / catch

try:
    org_cmd.list()
except SystemExit:
    # message already printed; inspect it for the HTTP status before deciding
    raise

Prevention

When it happens

Trigger: Running `crewai org list` (or OrganizationCommand.list) when the Plus API returns 403 (account lacks org access), 404 (endpoint moved / stale CLI against old API), 429, or 5xx — any raise_for_status() failure that is not 401.

Common situations: Expired feature entitlements or suspended accounts, CLI version skew with API changes, CrewAI Plus incidents, or organization membership revoked while the token remains valid.

Related errors


AI-assisted analysis of crewAIInc/crewAI@754d7323be (2026-08-15). Data as JSON: /api/errors/0465199c0439909e. Report an issue: GitHub.