{"record":{"id":"419ee6bdee1e4582","repo":"plandex-ai/plandex","slug":"error-getting-org","errorCode":null,"errorMessage":"Error getting org: ","messagePattern":"Error getting org: ","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"app/server/handlers/invites.go","lineNumber":40,"sourceCode":"\tif os.Getenv(\"GOENV\") == \"development\" && os.Getenv(\"LOCAL_MODE\") == \"1\" {\n\t\twriteApiError(w, shared.ApiError{\n\t\t\tType:   shared.ApiErrorTypeOther,\n\t\t\tStatus: http.StatusForbidden,\n\t\t\tMsg:    \"Local mode is not supported for invites\",\n\t\t})\n\t\treturn\n\t}\n\n\tauth := Authenticate(w, r, true)\n\tif auth == nil {\n\t\treturn\n\t}\n\n\torg, err := db.GetOrg(auth.OrgId)\n\n\tif err != nil {\n\t\tlog.Printf(\"Error getting org: %v\\n\", err)\n\t\thttp.Error(w, \"Error getting org: \"+err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tif org.IsTrial {\n\t\twriteApiError(w, shared.ApiError{\n\t\t\tType:   shared.ApiErrorTypeTrialActionNotAllowed,\n\t\t\tStatus: http.StatusForbidden,\n\t\t\tMsg:    \"Trial user can't invite other users\",\n\t\t})\n\n\t\treturn\n\t}\n\n\tcurrentUserId := auth.User.Id\n\n\tvar req shared.InviteRequest\n\terr = json.NewDecoder(r.Body).Decode(&req)\n\tif err != nil {","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/handlers/invites.go#L22-L58","documentation":"InviteUserHandler calls db.GetOrg(auth.OrgId) to load the caller's organization before processing an invite. If the query fails, the handler responds 500 with 'Error getting org: <err>'. This is a server-side data-access failure, not a client input problem.","triggerScenarios":"The orgs row for auth.OrgId cannot be fetched: Postgres is unreachable, the connection pool is exhausted, the query fails/times out, or the orgs table schema is missing or out of date. Note a nonexistent org may also surface as an error here depending on GetOrg's implementation.","commonSituations":"DATABASE_URL misconfigured or Postgres down in the deployment; database migration not run after upgrade; stale auth token referencing a deleted org; transient network partition between server and DB.","solutions":["Read the underlying cause after 'Error getting org: ' in the response/log and fix that specific DB error","Verify DATABASE_URL and that Postgres is reachable from the server (pg_isready, connection limits)","Run pending Plandex database migrations, then retry","If the token references a deleted org, sign out and back in to obtain a fresh org context; retry on transient failures"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Pre-check: confirm your token resolves to an existing org via a cheap endpoint before inviting\norg, err := client.GetCurrentOrg(ctx)\nif err != nil || org == nil {\n    return fmt.Errorf(\"org unavailable, aborting invite: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"err := client.InviteUser(ctx, email, orgRoleId)\nif err != nil && strings.Contains(err.Error(), \"Error getting org\") {\n    // 500 — server DB issue; retry with backoff before surfacing to the user\n    return retryWithBackoff(func() error { return client.InviteUser(ctx, email, orgRoleId) })\n}","preventionTips":["Check server/DB health endpoints before bulk inviting","Verify DATABASE_URL and Postgres connectivity on 500 spikes","Re-authenticate if your token may reference a deleted org","Apply DB migrations after every Plandex upgrade"],"tags":["database","postgres","http","go"],"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"}