{"record":{"id":"e71a93157e5b48c9","repo":"Significant-Gravitas/AutoGPT","slug":"this-invitation-was-sent-to-a-different-email-addr","errorCode":null,"errorMessage":"This invitation was sent to a different email address","messagePattern":"This invitation was sent to a different email address","errorType":"http","errorClass":"HTTPException","httpStatus":403,"severity":"warning","filePath":"autogpt_platform/backend/backend/api/features/orgs/invitation_routes.py","lineNumber":164,"sourceCode":"    token: str,\n    user_id: Annotated[str, Security(get_user_id)],\n) -> dict:\n    invitation = await prisma.orginvitation.find_unique(where={\"token\": token})\n    if invitation is None:\n        raise NotFoundError(\"Invitation not found\")\n    if invitation.acceptedAt is not None:\n        raise HTTPException(400, detail=\"Invitation already accepted\")\n    if invitation.revokedAt is not None:\n        raise HTTPException(400, detail=\"Invitation has been revoked\")\n    if invitation.expiresAt < datetime.now(timezone.utc):\n        raise HTTPException(400, detail=\"Invitation has expired\")\n\n    # Verify the accepting user's email matches the invitation\n    accepting_user = await prisma.user.find_unique(where={\"id\": user_id})\n    if accepting_user is None:\n        raise HTTPException(401, detail=\"User not found\")\n    if accepting_user.email.lower() != invitation.email.lower():\n        raise HTTPException(\n            403,\n            detail=\"This invitation was sent to a different email address\",\n        )\n\n    # Add user to org (idempotent — handles race condition from concurrent accepts)\n    try:\n        await org_db.add_org_member(\n            org_id=invitation.orgId,\n            user_id=user_id,\n            is_admin=invitation.isAdmin,\n            is_billing_manager=invitation.isBillingManager,\n            invited_by=invitation.invitedByUserId,\n        )\n    except UniqueViolationError:\n        # User is already a member — treat as success (idempotent)\n        pass\n\n    # Add to specified workspaces. Failures are non-fatal (a team may have","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/features/orgs/invitation_routes.py#L146-L182","documentation":"Raised by POST /api/invitations/{token}/accept when the authenticated user's email (case-insensitively) does not match the email the invitation was sent to. Invitations are bound to a recipient address; only that account may accept. HTTP 403.","triggerScenarios":"User logged in with a different account (e.g., personal Google account) than the email that received the invite; case variants are tolerated but different mailboxes are not; invitee changed their primary email after the invite was sent.","commonSituations":"Google/SSO login picks a different account than expected; invite sent to work address but user browses logged in with personal address; shared inboxes where someone else clicks the link.","solutions":["Log out and back in with exactly the account whose email received the invitation.","If the recipient's address changed, ask the admin to revoke and resend the invitation to the new address.","Admins: before resending, confirm the address with the invitee to avoid another mismatch."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const me = await api.get('/api/user/me').then(r => r.data);\nconst emailMatches = me.email.toLowerCase() === invitedEmail.toLowerCase();\nif (!emailMatches) show(`Switch to the account for ${invitedEmail} to accept.`);","typeGuard":null,"tryCatchPattern":"try {\n  await api.post(`/api/invitations/${token}/accept`);\n} catch (e) {\n  if (e.status === 403) { show('Log in with the invited email address.'); return; }\n  throw e;\n}","preventionTips":["Display the invited email on the acceptance screen before submit","Warn users with multiple accounts to pick the invited one","Admins: confirm recipient address before sending invites"],"tags":["invitations","email-mismatch","authorization","http-403"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}