{"record":{"id":"ed52e9f48587c418","repo":"plandex-ai/plandex","slug":"error-updating-org-user-config","errorCode":null,"errorMessage":"Error updating org user config: ","messagePattern":"Error updating org user config: ","errorType":"http","errorClass":"http","httpStatus":500,"severity":"error","filePath":"app/server/handlers/sessions.go","lineNumber":341,"sourceCode":"\tif err != nil {\n\t\tlog.Printf(\"Error reading request body: %v\\n\", err)\n\t\thttp.Error(w, \"Error reading request body: \"+err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tvar req shared.OrgUserConfig\n\terr = json.Unmarshal(body, &req)\n\tif err != nil {\n\t\tlog.Printf(\"Error unmarshalling request: %v\\n\", err)\n\t\thttp.Error(w, \"Error unmarshalling request: \"+err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\terr = db.UpdateOrgUserConfig(auth.User.Id, auth.OrgId, &req)\n\n\tif err != nil {\n\t\tlog.Printf(\"Error updating org user config: %v\\n\", err)\n\t\thttp.Error(w, \"Error updating org user config: \"+err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tlog.Println(\"Successfully updated org user config\")\n}\n","sourceCodeStart":323,"sourceCodeEnd":347,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/handlers/sessions.go#L323-L347","documentation":"UpdateOrgUserConfigHandler calls db.UpdateOrgUserConfig to persist an org-user config row for the authenticated user and org. When the underlying database update returns an error, the handler logs it and responds with HTTP 500 including the raw error string. This is a server-side persistence failure, not a client input problem.","triggerScenarios":"db.UpdateOrgUserConfig(auth.User.Id, auth.OrgId, &req) returns a non-nil error: database connection failure, constraint violation, invalid config JSON, missing user/org row, or storage backend unavailable.","commonSituations":"Postgres/DB is down or unreachable; the org-user row does not exist for the given auth.OrgId and user id; config payload violates a schema or size constraint; DB migration drift between server versions.","solutions":["Check the server log line to see the wrapped DB error and fix the underlying cause","Verify the user/org record exists before updating (insert-or-upsert instead of update)","Check database connectivity and credentials of the server's DB connection","Validate the request payload against the OrgUserConfig schema before calling UpdateOrgUserConfig","Confirm DB migrations are up to date for the org_user_configs table"],"exampleFix":"// before\nerr = db.UpdateOrgUserConfig(auth.User.Id, auth.OrgId, &req)\n// after\nif err := validateOrgUserConfig(&req); err != nil {\n    http.Error(w, \"Invalid org user config: \"+err.Error(), http.StatusBadRequest)\n    return\n}\nerr = db.UpdateOrgUserConfig(auth.User.Id, auth.OrgId, &req)","handlingStrategy":"validation","validationCode":"if req == nil || auth == nil || auth.User == nil || auth.OrgId == \"\" {\n    return errors.New(\"missing auth or empty request\")\n}","typeGuard":null,"tryCatchPattern":"resp, err := client.UpdateOrgUserConfig(ctx, req)\nif err != nil {\n    if strings.Contains(err.Error(), \"Error updating org user config\") {\n        // server-side persistence failed: check server logs / retry later\n    }\n    return err\n}","preventionTips":["Validate the config payload against the schema before sending","Ensure the org-user relationship exists (e.g., user is a member of the org)","Monitor server DB health before config updates","Retry idempotent updates on transient DB errors"],"tags":["http","database","go"],"backgroundTag":"database-update-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"}