{"record":{"id":"40f4bee999f31ba7","repo":"plandex-ai/plandex","slug":"error-marshalling-response-40f4be","errorCode":null,"errorMessage":"Error marshalling response","messagePattern":"Error marshalling response","errorType":"http","errorClass":"http","httpStatus":500,"severity":"error","filePath":"app/server/handlers/settings.go","lineNumber":215,"sourceCode":"\t\t}\n\n\t\treturn nil\n\t})\n\n\tif err != nil {\n\t\tlog.Println(\"Error updating settings: \", err)\n\t\thttp.Error(w, \"Error updating settings\", http.StatusInternalServerError)\n\t\treturn\n\t}\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\n\tlog.Println(\"UpdateSettingsHandler processed successfully\")\n\n}\n\nfunc GetDefaultSettingsHandler(w http.ResponseWriter, r *http.Request) {\n\tlog.Println(\"Received request for GetDefaultSettingsHandler\")\n\n\tauth := Authenticate(w, r, true)\n\tif auth == nil {\n\t\treturn\n\t}\n\n\tsettings, err := db.GetOrgDefaultSettings(auth.OrgId)","sourceCodeStart":197,"sourceCodeEnd":233,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/handlers/settings.go#L197-L233","documentation":"After a successful update, the handler marshals shared.UpdateSettingsResponse{Msg: commitMsg} to JSON. Failure is extremely unlikely for this fixed struct but would yield HTTP 500 'Error marshalling response'.","triggerScenarios":"json.Marshal(res) fails, practically only if UpdateSettingsResponse gains non-serializable fields or commitMsg carries values causing custom MarshalJSON to error.","commonSituations":"Code changes add a func/chan field or custom marshaler to UpdateSettingsResponse; build with mismatched shared package versions.","solutions":["Keep UpdateSettingsResponse JSON-safe (strings/basic types only)","If a custom MarshalJSON exists on the response, fix its error path","Pin the shared package version to match the server build"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"resp, err := client.UpdateSettings(ctx, req)\nif err != nil {\n    // 500 'Error marshalling response' is a server bug; surface it and stop\n    return fmt.Errorf(\"settings updated but response malformed: %w\", err)\n}","preventionTips":["Keep UpdateSettingsResponse fields JSON-safe when modifying shared types","Add a unit test marshaling the response struct after schema changes","Pin shared package versions across server builds"],"tags":["json","go","serialization"],"backgroundTag":"json-marshal-failed","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}