{"record":{"id":"290b1847689c6e17","repo":"plandex-ai/plandex","slug":"error-marshalling-response-290b18","errorCode":null,"errorMessage":"Error marshalling response","messagePattern":"Error marshalling response","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"app/server/handlers/plan_config.go","lineNumber":48,"sourceCode":"\tif plan == nil {\n\t\treturn\n\t}\n\n\tconfig, err := db.GetPlanConfig(planId)\n\tif err != nil {\n\t\tlog.Println(\"Error getting plan config: \", err)\n\t\thttp.Error(w, \"Error getting plan config\", http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tres := shared.GetPlanConfigResponse{\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(\"GetPlanConfigHandler processed successfully\")\n}\n\nfunc UpdatePlanConfigHandler(w http.ResponseWriter, r *http.Request) {\n\tlog.Println(\"Received request for UpdatePlanConfigHandler\")\n\n\tauth := Authenticate(w, r, true)\n\tif auth == nil {\n\t\treturn\n\t}\n\n\tvars := mux.Vars(r)\n\tplanId := vars[\"planId\"]\n","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/handlers/plan_config.go#L30-L66","documentation":"json.Marshal(shared.GetPlanConfigResponse) failed, returning HTTP 500. Since Go's encoding/json only errors on unsupported values (chan, func, complex, cyclic data), this points to a defect in the response struct or a custom marshaler, not client input.","triggerScenarios":"The fetched plan config response struct contains an unserializable field (e.g. a channel or function), a field's MarshalJSON method errors, or a cyclic reference exists in nested config data.","commonSituations":"Newly added config field of unsupported type, accidentally embedding a DB model with a sqlx-specific unserializable type, custom MarshalJSON returning an error on odd stored values.","solutions":["Read the logged marshal error to identify the offending field","Audit GetPlanConfigResponse and the PlanConfig model for unsupported field types","Add a regression test marshaling a fully populated GetPlanConfigResponse","Ensure config values loaded from the DB are deserialized into API-safe types first"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// server-side: CI test for the response shape\nfunc TestGetPlanConfigResponseMarshal(t *testing.T) {\n    _, err := json.Marshal(shared.GetPlanConfigResponse{Config: sampleConfig()})\n    if err != nil { t.Fatal(err) }\n}","typeGuard":null,"tryCatchPattern":"bytes, err := json.Marshal(res)\nif err != nil {\n    log.Printf(\"Error marshalling response: %v\", err)\n    http.Error(w, \"Error marshalling response\", http.StatusInternalServerError)\n    return\n}","preventionTips":["Use JSON-safe types in shared response structs","Add marshal regression tests for all response types","Avoid embedding raw DB models in responses","Review any custom MarshalJSON for error returns"],"tags":["json","serialization","http-500"],"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-14T00:17:10.932Z"}