{"record":{"id":"91ddf99001ebe8f5","repo":"Significant-Gravitas/AutoGPT","slug":"user-is-not-a-member-of-the-specified-organization","errorCode":null,"errorMessage":"User is not a member of the specified organization","messagePattern":"User is not a member of the specified organization","errorType":"exception","errorClass":"PreconditionFailed","httpStatus":428,"severity":"error","filePath":"autogpt_platform/backend/backend/api/features/store/db.py","lineNumber":871,"sourceCode":"        sub_heading: Optional sub-heading for the agent\n        categories: List of categories for the agent\n        changes_summary: Summary of changes made in this submission\n\n    Returns:\n        StoreSubmission: The created store submission\n    \"\"\"\n    logger.debug(\n        f\"Creating store submission for user #{user_id}, \"\n        f\"graph #{graph_id} v{graph_version}\"\n    )\n\n    async def verify_org_membership(org_id: str, uid: str) -> None:\n        \"\"\"Check that user is a member of the specified organization.\"\"\"\n        member = await prisma.models.OrgMember.prisma().find_first(\n            where={\"orgId\": org_id, \"userId\": uid}\n        )\n        if not member:\n            raise PreconditionFailed(\n                \"User is not a member of the specified organization\"\n            )\n\n    try:\n        # Verify org membership when submitting on behalf of an organization\n        if organization_id:\n            await verify_org_membership(organization_id, user_id)\n\n        # Sanitize slug to only allow letters and hyphens\n        slug = \"\".join(\n            c if c.isalpha() or c == \"-\" or c.isnumeric() else \"\" for c in slug\n        ).lower()\n\n        # First verify the agent graph belongs to this user\n        graph = await prisma.models.AgentGraph.prisma().find_first(\n            where={\"id\": graph_id, \"version\": graph_version, \"userId\": user_id},\n            include={\"User\": {\"include\": {\"Profile\": True}}},\n        )","sourceCodeStart":853,"sourceCodeEnd":889,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/features/store/db.py#L853-L889","documentation":"PreconditionFailed raised inside create_store_submission when organization_id is provided but no OrgMember row links the authenticated user to that organization. It is an authorization-of-intent check: you may only submit an agent to a store listing owned by an organization you belong to. The API maps PreconditionFailed to HTTP 412/409-class responses, telling the client to fix state before retrying.","triggerScenarios":"POST /store/submissions with body organization_id set to an org the user has never joined, was removed from, or a typo'd/stale org ID from the frontend's local state.","commonSituations":"User was kicked out of a team but the UI still shows the org selector; frontend caching an old org list; testing with a user account that was never invited to the target org.","solutions":["Refetch the user's organizations (GET the org-membership endpoint) and re-render the selector before submission.","Confirm the user has an accepted membership row in OrgMember for that orgId in the DB.","If membership should exist, check you are sending the correct organization_id (not the workspace or team name)."],"exampleFix":"// before\nawait api.createSubmission({ graph_id, organization_id: cachedOrg.id, ... });\n// after\nconst orgs = await api.getMyOrganizations();\nconst org = orgs.find(o => o.id === organization_id);\nif (!org) throw new Error('You are not a member of this organization');\nawait api.createSubmission({ graph_id, organization_id: org.id, ... });","handlingStrategy":"validation","validationCode":"const memberships = await api.getMyOrganizations();\nconst isMember = memberships.some(o => o.id === form.organization_id);\nif (form.organization_id && !isMember) {\n  setError('You are no longer a member of this team');\n  return;\n}\nawait api.createSubmission(form);","typeGuard":null,"tryCatchPattern":"from backend.util.exceptions import PreconditionFailed\n\ntry:\n    sub = await store_db.create_store_submission(...)\nexcept PreconditionFailed as e:\n    if 'organization' in str(e):\n        ui.show('Join the organization before submitting on its behalf');\n        return;\n    raise","preventionTips":["Fetch org memberships when opening the publish dialog, not from cache.","Refresh the org selector after membership changes (invite accepted, removed).","Default organization_id to null (personal) rather than a remembered org."],"tags":["authorization","organizations","store","submission"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}