Significant-Gravitas/AutoGPT · error · NotFoundError

Organization {org_id} not found

Error message

Organization {org_id} not found

What it means

NotFoundError raised by get_org when no organization row exists for org_id, or the row exists but has deletedAt set (soft-deleted). Reads deliberately exclude soft-deleted orgs, so a deleted org looks the same as one that never existed.

Source

Thrown at autogpt_platform/backend/backend/api/features/orgs/db.py:327

            "status": "ACTIVE",
            "Org": {"deletedAt": None},
        },
        include={"Org": True},
    )
    results = []
    for m in memberships:
        org = m.Org
        if org is None:
            continue
        results.append(OrgResponse.from_db(org))
    return results


async def get_org(org_id: str) -> OrgResponse:
    """Get organization details."""
    org = await prisma.organization.find_unique(where={"id": org_id})
    if org is None or org.deletedAt is not None:
        raise NotFoundError(f"Organization {org_id} not found")
    return OrgResponse.from_db(org)


async def update_org(org_id: str, data: UpdateOrgData) -> OrgResponse:
    """Update organization fields. Creates a RENAME alias if slug changes.

    Only accepts the structured UpdateOrgData model — no arbitrary dict keys.
    """
    update_dict: dict = {}
    if data.name is not None:
        update_dict["name"] = data.name
    if data.description is not None:
        update_dict["description"] = data.description
    if data.avatar_url is not None:
        update_dict["avatarUrl"] = data.avatar_url

    if data.slug is not None:
        existing = await prisma.organization.find_unique(where={"slug": data.slug})

View on GitHub (pinned to 9c8bb5550f)

Solutions

  1. Re-fetch the user's org list and use a current org id
  2. If the org was deleted, restore/recreate it or update the client to drop the reference
  3. Verify the id matches the environment you are calling
Defensive patterns

Strategy: validation

Validate before calling

orgs = await list_orgs_for_user(user_id)
if org_id not in {o.id for o in orgs}:
    raise LookupError(f"org {org_id} not visible — refresh references")

Type guard

def is_visible_org(org_id: str, known_orgs: list[str]) -> bool:
    return org_id in known_orgs

Try / catch

try:
    org = await get_org(org_id)
except NotFoundError:
    orgs = await list_orgs_for_user(user_id)
    org = next((o for o in orgs if o.id == org_id), None) or refresh_references()

Prevention

When it happens

Trigger: GET organization details with a wrong/typo'd org_id, an id from another environment, or the id of an org that was soft-deleted.

Common situations: Frontend holding a stale org reference after deletion; org ids copied between staging and production; recent deletion not yet reflected in the caller's cached list.

Related errors


AI-assisted analysis of Significant-Gravitas/AutoGPT@9c8bb5550f (2026-08-14). Data as JSON: /api/errors/8c18bba01210c50a. Report an issue: GitHub.