{"record":{"id":"c7c15c641acee2cb","repo":"plandex-ai/plandex","slug":"error-getting-org-user-config-c7c15c","errorCode":null,"errorMessage":"Error getting org user config: ","messagePattern":"Error getting org user config: ","errorType":"http","errorClass":"http","httpStatus":500,"severity":"error","filePath":"app/server/handlers/sessions.go","lineNumber":299,"sourceCode":"\t\treturn\n\t}\n\n\tlog.Println(\"Successfully signed out\")\n}\n\nfunc GetOrgUserConfigHandler(w http.ResponseWriter, r *http.Request) {\n\tlog.Println(\"Received request for GetOrgUserConfigHandler\")\n\n\tauth := Authenticate(w, r, true)\n\tif auth == nil {\n\t\treturn\n\t}\n\n\torgUserConfig, err := db.GetOrgUserConfig(auth.User.Id, auth.OrgId)\n\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: \"+err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tbytes, err := json.Marshal(orgUserConfig)\n\n\tif err != nil {\n\t\tlog.Printf(\"Error marshalling response: %v\\n\", err)\n\t\thttp.Error(w, \"Error marshalling response: \"+err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tw.Write(bytes)\n}\n\nfunc UpdateOrgUserConfigHandler(w http.ResponseWriter, r *http.Request) {\n\tlog.Println(\"Received request for UpdateOrgUserConfigHandler\")\n\n\tauth := Authenticate(w, r, true)","sourceCodeStart":281,"sourceCodeEnd":317,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/handlers/sessions.go#L281-L317","documentation":"GetOrgUserConfigHandler fails at app/server/handlers/sessions.go:295-300 when db.GetOrgUserConfig(auth.User.Id, auth.OrgId) returns an error fetching the organization-user configuration row. This is a database-layer failure: no/failed query, connection issue, or scan error mapping the row into the config struct.","triggerScenarios":"Authenticated GET of org user config where the underlying SELECT fails: database unreachable, org_user_config table/columns missing, row cannot be scanned into the expected struct, or the (user_id, org_id) lookup errors.","commonSituations":"Migrations not applied after a schema change, Postgres down or connection pool exhausted, column type changed so rows.Scan fails, or stale app deployed against a newer schema.","solutions":["Read the logged 'Error getting org user config: ...' text to distinguish connection errors from scan/SQL errors","Run pending database migrations and verify the org_user_config table/columns exist","Verify Postgres connectivity and pool health from the app host","Check that GetOrgUserConfig's scan destinations match the current table column types"],"exampleFix":"// before\nif err != nil {\n\thttp.Error(w, \"Error getting org user config: \"+err.Error(), http.StatusInternalServerError)\n\treturn\n}\n// after\nif err != nil {\n\tif errors.Is(err, sql.ErrNoRows) {\n\t\tcfg := shared.DefaultOrgUserConfig() // return defaults instead of 500\n\t\twriteJSON(w, cfg)\n\t\treturn\n\t}\n\tlog.Printf(\"Error getting org user config: %v\\n\", err)\n\thttp.Error(w, \"Error getting org user config\", http.StatusInternalServerError)\n\treturn\n}","handlingStrategy":"retry","validationCode":"// caller-side readiness probe\nif err := db.Conn.Ping(ctx); err != nil {\n\treturn fmt.Errorf(\"database unavailable: %w\", err)\n}","typeGuard":"func isMissingSchemaError(err error) bool {\n\tvar pgErr *pgconn.PgError\n\treturn errors.As(err, &pgErr) && (pgErr.Code == \"42P01\" || pgErr.Code == \"42703\") // undefined table/column\n}","tryCatchPattern":"cfg, err := db.GetOrgUserConfig(userID, orgID)\nif err != nil {\n\tif isMissingSchemaError(err) {\n\t\treturn nil, fmt.Errorf(\"schema out of date; run migrations: %w\", err)\n\t}\n\tif isTransientDBError(err) {\n\t\t// retry once with backoff\n\t\ttime.Sleep(time.Second)\n\t\treturn db.GetOrgUserConfig(userID, orgID)\n\t}\n\treturn nil, err\n}","preventionTips":["Run migrations as part of every deploy","Ping/health-check the DB before serving config reads","Return stored defaults when the config row is absent instead of failing","Retry only transient errors (timeouts, connection resets), not SQL schema errors"],"tags":["go","database","postgres","sql"],"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"}