{"record":{"id":"8c18bba01210c50a","repo":"Significant-Gravitas/AutoGPT","slug":"organization-org-id-not-found","errorCode":null,"errorMessage":"Organization {org_id} not found","messagePattern":"Organization (.+?) not found","errorType":"http","errorClass":"NotFoundError","httpStatus":404,"severity":"error","filePath":"autogpt_platform/backend/backend/api/features/orgs/db.py","lineNumber":327,"sourceCode":"            \"status\": \"ACTIVE\",\n            \"Org\": {\"deletedAt\": None},\n        },\n        include={\"Org\": True},\n    )\n    results = []\n    for m in memberships:\n        org = m.Org\n        if org is None:\n            continue\n        results.append(OrgResponse.from_db(org))\n    return results\n\n\nasync def get_org(org_id: str) -> OrgResponse:\n    \"\"\"Get organization details.\"\"\"\n    org = await prisma.organization.find_unique(where={\"id\": org_id})\n    if org is None or org.deletedAt is not None:\n        raise NotFoundError(f\"Organization {org_id} not found\")\n    return OrgResponse.from_db(org)\n\n\nasync def update_org(org_id: str, data: UpdateOrgData) -> OrgResponse:\n    \"\"\"Update organization fields. Creates a RENAME alias if slug changes.\n\n    Only accepts the structured UpdateOrgData model — no arbitrary dict keys.\n    \"\"\"\n    update_dict: dict = {}\n    if data.name is not None:\n        update_dict[\"name\"] = data.name\n    if data.description is not None:\n        update_dict[\"description\"] = data.description\n    if data.avatar_url is not None:\n        update_dict[\"avatarUrl\"] = data.avatar_url\n\n    if data.slug is not None:\n        existing = await prisma.organization.find_unique(where={\"slug\": data.slug})","sourceCodeStart":309,"sourceCodeEnd":345,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/features/orgs/db.py#L309-L345","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Re-fetch the user's org list and use a current org id","If the org was deleted, restore/recreate it or update the client to drop the reference","Verify the id matches the environment you are calling"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"orgs = await list_orgs_for_user(user_id)\nif org_id not in {o.id for o in orgs}:\n    raise LookupError(f\"org {org_id} not visible — refresh references\")","typeGuard":"def is_visible_org(org_id: str, known_orgs: list[str]) -> bool:\n    return org_id in known_orgs","tryCatchPattern":"try:\n    org = await get_org(org_id)\nexcept NotFoundError:\n    orgs = await list_orgs_for_user(user_id)\n    org = next((o for o in orgs if o.id == org_id), None) or refresh_references()","preventionTips":["Refresh org references after any delete/rename flow","Treat 404/NotFoundError as 'gone' — purge cached ids","Scope org ids per environment in configuration"],"tags":["orgs","http-404","not-found","soft-delete"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}