{"record":{"id":"2291cf3edbb122a9","repo":"plandex-ai/plandex","slug":"error-getting-default-plan-config","errorCode":null,"errorMessage":"Error getting default plan config","messagePattern":"Error getting default plan config","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"app/server/handlers/plan_config.go","lineNumber":103,"sourceCode":"\t\thttp.Error(w, \"Error storing plan config\", http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tlog.Println(\"UpdatePlanConfigHandler processed successfully\")\n}\n\nfunc GetDefaultPlanConfigHandler(w http.ResponseWriter, r *http.Request) {\n\tlog.Println(\"Received request for GetDefaultPlanConfigHandler\")\n\n\tauth := Authenticate(w, r, true)\n\tif auth == nil {\n\t\treturn\n\t}\n\n\tconfig, err := db.GetDefaultPlanConfig(auth.User.Id)\n\tif err != nil {\n\t\tlog.Println(\"Error getting default plan config: \", err)\n\t\thttp.Error(w, \"Error getting default plan config\", http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tres := shared.GetDefaultPlanConfigResponse{\n\t\tConfig: config,\n\t}\n\n\tbytes, err := json.Marshal(res)\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\tlog.Println(\"GetDefaultPlanConfigHandler processed successfully\")\n}\n","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/handlers/plan_config.go#L85-L121","documentation":"GetDefaultPlanConfigHandler returns HTTP 500 when db.GetDefaultPlanConfig(auth.User.Id) errors. It fetches the user's default plan settings; failures are DB-side (query, scan, or connectivity) since only the authenticated user's ID is used.","triggerScenarios":"GET default plan config when the user_settings/default-config row for auth.User.Id cannot be read, the DB is unreachable, or the stored default config fails to scan/deserialize (e.g. corrupt JSON).","commonSituations":"Brand-new user with no row and the query not treating missing-row as empty, schema drift after upgrade, manually edited default config containing invalid JSON, transient Postgres outages.","solutions":["Check server logs for \"Error getting default plan config: <err>\" to see the cause","Run pending migrations so the default-config table matches the model","Treat missing rows as an empty default config instead of an error (sql.ErrNoRows handling)","Repair or reset corrupt default-config rows for the affected user"],"exampleFix":"// before\nconfig, err := db.GetDefaultPlanConfig(auth.User.Id)\nif err != nil {\n    http.Error(w, \"Error getting default plan config\", http.StatusInternalServerError)\n    return\n}\n// after\nconfig, err := db.GetDefaultPlanConfig(auth.User.Id)\nif errors.Is(err, sql.ErrNoRows) {\n    config = shared.DefaultPlanConfig()\n} else if err != nil {\n    http.Error(w, \"Error getting default plan config\", http.StatusInternalServerError)\n    return\n}","handlingStrategy":"try-catch","validationCode":"// client: ensure user is authenticated first\nif (!authToken) return;\nconst res = await fetch(base + '/plans/default-config', { headers: { Authorization: 'Bearer ' + authToken } });\nif (res.status === 500) console.error('default config lookup failed; check server DB logs');","typeGuard":null,"tryCatchPattern":"try {\n  const cfg = await getDefaultPlanConfig();\n} catch (e) {\n  if (e.status === 500) { /* fall back to client defaults and report server issue */ }\n  else throw e;\n}","preventionTips":["Return empty defaults when the user has no stored config (sql.ErrNoRows)","Run migrations on every deploy","Validate stored default-config JSON integrity","Monitor DB availability with health checks"],"tags":["database","http-500","default-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"}