{"record":{"id":"ffb36ddb3064a001","repo":"plandex-ai/plandex","slug":"error-updating-default-settings","errorCode":null,"errorMessage":"Error updating default settings","messagePattern":"Error updating default settings","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"app/server/handlers/settings.go","lineNumber":322,"sourceCode":"\t\t// log.Println(\"Original settings:\")\n\t\t// spew.Dump(originalSettings)\n\n\t\t// log.Println(\"req.Settings:\")\n\t\t// spew.Dump(req.Settings)\n\n\t\terr = db.StoreOrgDefaultSettings(auth.OrgId, settings, tx)\n\n\t\tif err != nil {\n\t\t\tlog.Println(\"Error storing default settings: \", err)\n\t\t\treturn fmt.Errorf(\"error storing default settings: %v\", err)\n\t\t}\n\n\t\treturn nil\n\t})\n\n\tif err != nil {\n\t\tlog.Println(\"Error updating default settings: \", err)\n\t\thttp.Error(w, \"Error updating default settings\", http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tcommitMsg := getUpdateCommitMsg(settings, originalSettings, true)\n\n\tres := shared.UpdateSettingsResponse{\n\t\tMsg: commitMsg,\n\t}\n\tbytes, err := json.Marshal(res)\n\n\tif err != nil {\n\t\tlog.Println(\"Error marshalling response: \", err)\n\t\thttp.Error(w, \"Error marshalling response\", http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tw.Write(bytes)\n","sourceCodeStart":304,"sourceCodeEnd":340,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/handlers/settings.go#L304-L340","documentation":"UpdateDefaultSettingsHandler runs its work inside db.WithTx: it locks/reads current defaults (GetOrgDefaultSettingsForUpdate), deep-copies them, applies the model pack change, and stores them. Any error returned by the transaction closure (get-for-update failure, DeepCopy failure, unknown model pack name, store failure, or the tx itself failing to commit) is surfaced as 500 'Error updating default settings'.","triggerScenarios":"Tx cannot read the org default row for update (missing row, lock timeout, deadlocks), DeepCopy fails, req.ModelPackName doesn't match any known model pack, StoreOrgDefaultSettings hits a constraint/DB error, or commit fails due to serialization/conflict.","commonSituations":"Concurrent settings updates from two admins causing lock waits/deadlocks; typo'd model pack name that SetModelPackByName can't resolve; migration lag so the settings row or columns don't exist; DB connection drop mid-transaction.","solutions":["Read the 'Error updating default settings:' line in server logs for the wrapped cause (it prefixes 'error getting/storing/copying settings')","Verify the modelPackName matches an existing model pack exactly","Check DB health, lock contention, and that migrations are current","Retry the update if it failed on a transient deadlock or serialization error","If concurrent edits are common, serialize updates per org on the client side"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// client-side pre-check\nif (!hasModelPack(req)) throw new Error('modelPackName or modelPack required');\nconst knownPacks = await api.listModelPacks();\nif (req.modelPackName && !knownPacks.includes(req.modelPackName)) {\n  throw new Error(`Unknown model pack: ${req.modelPackName}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await api.updateDefaultSettings(req);\n} catch (e) {\n  if (isTransient(e)) await backoffRetry(req, 3);\n  else throw e;\n}","preventionTips":["Verify the model pack name exists before sending","Retry on transient DB errors (deadlock, serialization) with backoff","Avoid concurrent settings updates from multiple admins on the same org","Keep migrations current so the settings tables match the code"],"tags":["database","transaction","settings","http-500"],"backgroundTag":"transaction-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"}