{"record":{"id":"b33b405600f6505f","repo":"plandex-ai/plandex","slug":"error-accepting-invite","errorCode":null,"errorMessage":"error accepting invite","messagePattern":"error accepting invite","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"app/server/handlers/auth_helpers.go","lineNumber":554,"sourceCode":"\t\tinvite, err := db.GetActiveInviteByEmail(parsed.OrgId, user.Email)\n\n\t\tif err != nil {\n\t\t\tlog.Printf(\"error getting invite for org user: %v\\n\", err)\n\t\t\tif raiseErr {\n\t\t\t\thttp.Error(w, \"error getting invite for org user\", http.StatusInternalServerError)\n\t\t\t}\n\t\t\treturn nil\n\t\t}\n\n\t\tif invite != nil {\n\t\t\tlog.Println(\"accepting invite\")\n\n\t\t\terr := db.AcceptInvite(r.Context(), invite, authToken.UserId)\n\n\t\t\tif err != nil {\n\t\t\t\tlog.Printf(\"error accepting invite: %v\\n\", err)\n\t\t\t\tif raiseErr {\n\t\t\t\t\thttp.Error(w, \"error accepting invite\", http.StatusInternalServerError)\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t} else {\n\t\t\tlog.Println(\"user is not a member of the org\")\n\t\t\tif raiseErr {\n\t\t\t\thttp.Error(w, \"not a member of org\", http.StatusUnauthorized)\n\t\t\t}\n\t\t\treturn nil\n\t\t}\n\t}\n\n\t// get user permissions\n\tpermissions, err := db.GetUserPermissions(authToken.UserId, parsed.OrgId)\n\n\tif err != nil {\n\t\tlog.Printf(\"error getting user permissions: %v\\n\", err)","sourceCodeStart":536,"sourceCodeEnd":572,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/handlers/auth_helpers.go#L536-L572","documentation":"A pending invite was found and db.AcceptInvite(r.Context(), invite, authToken.UserId) failed; the server logs 'error accepting invite' and returns HTTP 500 when raiseErr is true. The auto-accept flow that adds the user to the org on first authenticated access failed.","triggerScenarios":"User with a valid active invite authenticates against the org; the AcceptInvite transaction fails (DB error, context cancellation, constraint conflict).","commonSituations":"Database outages or transaction deadlocks; request context cancelled/timeouts mid-write; concurrent invite acceptance or already-added membership causing constraint violations.","solutions":["Retry the request; on success the invite will auto-accept again","Check server logs for the underlying db.AcceptInvite error","Inspect for constraint conflicts (user already added) and make AcceptInvite idempotent","Verify the request is not timing out before the DB transaction completes"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := doCall(ctx); err != nil {\n\tvar apiErr *APIError\n\tif errors.As(err, &apiErr) && apiErr.StatusCode == 500 && strings.Contains(apiErr.Message, \"accepting invite\") {\n\t\treturn retryWithBackoff(ctx) // re-attempt; invite auto-accepts on success\n\t}\n\treturn err\n}","preventionTips":["Make AcceptInvite idempotent (handle already-member constraint)","Keep DB transactions short to avoid deadlocks/context cancellation","Monitor DB errors during invite acceptance flows","Retry client-side on 500 with backoff before surfacing to the user"],"tags":["database","invites","internal-server-error"],"backgroundTag":"database-query-failed","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}