{"record":{"id":"39fd6184f6409114","repo":"plandex-ai/plandex","slug":"error-getting-org-user-config-39fd61","errorCode":null,"errorMessage":"Error getting org user config","messagePattern":"Error getting org user config","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"app/server/handlers/plans_exec.go","lineNumber":82,"sourceCode":"\t\tgo notify.NotifyErr(notify.SeverityError, fmt.Errorf(\"error parsing request body: %v\", err))\n\t\thttp.Error(w, \"Error parsing request body\", http.StatusBadRequest)\n\t\treturn\n\t}\n\n\t_, apiErr := hooks.ExecHook(hooks.WillTellPlan, hooks.HookParams{\n\t\tAuth: auth,\n\t\tPlan: plan,\n\t})\n\tif apiErr != nil {\n\t\tgo notify.NotifyErr(notify.SeverityError, fmt.Errorf(\"error executing will tell plan hook: %v\", apiErr))\n\t\twriteApiError(w, *apiErr)\n\t\treturn\n\t}\n\n\torgUserConfig, err := db.GetOrgUserConfig(auth.User.Id, auth.OrgId)\n\tif err != nil {\n\t\tlog.Printf(\"Error getting org user config: %v\\n\", err)\n\t\thttp.Error(w, \"Error getting org user config\", http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tres := initClients(\n\t\tinitClientsParams{\n\t\t\tw:             w,\n\t\t\tauth:          auth,\n\t\t\tapiKeys:       requestBody.ApiKeys,\n\t\t\topenAIOrgId:   requestBody.OpenAIOrgId,\n\t\t\tauthVars:      requestBody.AuthVars,\n\t\t\tplan:          plan,\n\t\t\tsettings:      settings,\n\t\t\torgUserConfig: orgUserConfig,\n\t\t},\n\t)\n\terr = modelPlan.Tell(modelPlan.TellParams{\n\t\tClients:  res.clients,\n\t\tPlan:     plan,","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/handlers/plans_exec.go#L64-L100","documentation":"TellPlanHandler loads the user's per-org configuration via db.GetOrgUserConfig(auth.User.Id, auth.OrgId) to build model clients. A failure here means the database lookup for the org-user config row errored; the handler responds 500 'Error getting org user config'. This is a server-side persistence problem, not something the request body influences.","triggerScenarios":"Authenticated tell-plan request where the org_user_configs table is unreadable, the row for (userId, orgId) query fails, the database connection is down, or the migration state is inconsistent with the running binary.","commonSituations":"Postgres/SQLite outage or connection-pool exhaustion; user removed from the org after the auth token was issued; schema migrations not applied after upgrading the server.","solutions":["Check database connectivity and health (db logs, `SELECT` on the org_user_configs table for the user/org ids).","Re-authenticate so a fresh token bound to a still-valid org membership is used.","Run pending database migrations for the server version and restart the server.","If self-hosting, verify DB env vars (host, credentials, pool limits) and that the storage volume is writable."],"exampleFix":"// after: fail fast with a clear startup check\ncfg, err := db.GetOrgUserConfig(auth.User.Id, auth.OrgId)\nif err != nil {\n    log.Printf(\"Error getting org user config for user %s org %s: %v\", auth.User.Id, auth.OrgId, err)\n    http.Error(w, \"Error getting org user config\", http.StatusInternalServerError)\n    return\n}","handlingStrategy":"retry","validationCode":"// pre-flight DB health check the operator can run\n// psql $DATABASE_URL -c \"SELECT 1 FROM org_user_configs LIMIT 1;\"","typeGuard":null,"tryCatchPattern":"cfg, err := db.GetOrgUserConfig(userID, orgID)\nif err != nil {\n    if isTransientDBError(err) { time.Sleep(backoff); cfg, err = db.GetOrgUserConfig(userID, orgID) }\n    if err != nil { return err }\n}","preventionTips":["Keep DB migrations applied on every server upgrade.","Monitor DB connectivity/pool saturation in production.","Re-authenticate after org membership changes.","Verify org_user_configs rows exist for active users when onboarding."],"tags":["database","server-error","org-config"],"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-12T22:17:10.623Z"}