{"record":{"id":"e76bbe462ddc5f14","repo":"plandex-ai/plandex","slug":"error-marshalling-projects","errorCode":null,"errorMessage":"Error marshalling projects: ","messagePattern":"Error marshalling projects: ","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"app/server/handlers/projects.go","lineNumber":116,"sourceCode":"\t}\n\n\tvar projects []shared.Project\n\n\tfor rows.Next() {\n\t\tvar project shared.Project\n\t\terr := rows.Scan(&project.Id, &project.Name)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"Error scanning project: %v\\n\", err)\n\t\t\thttp.Error(w, \"Error scanning project: \"+err.Error(), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t\tprojects = append(projects, project)\n\t}\n\n\tbytes, err := json.Marshal(projects)\n\tif err != nil {\n\t\tlog.Printf(\"Error marshalling projects: %v\\n\", err)\n\t\thttp.Error(w, \"Error marshalling projects: \"+err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tw.Write(bytes)\n}\n\nfunc ProjectSetPlanHandler(w http.ResponseWriter, r *http.Request) {\n\tlog.Println(\"Received request for UpdateProjectSetPlanHandler\")\n\tauth := Authenticate(w, r, true)\n\tif auth == nil {\n\t\treturn\n\t}\n\n\tvars := mux.Vars(r)\n\tprojectId := vars[\"projectId\"]\n\n\tlog.Println(\"projectId: \", projectId)\n","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/handlers/projects.go#L98-L134","documentation":"After scanning all rows, the handler marshals the []shared.Project slice with encoding/json. Like error 1042, this is defensive: marshalling a slice of structs with string fields cannot realistically fail. If triggered, the handler returns 500 with the marshal error.","triggerScenarios":"Practically unreachable with the current shared.Project (Id, Name strings); would require the struct to gain unmarshalable fields (channels, funcs, cyclic pointers) or invalid UTF-8-only cases json can still encode.","commonSituations":"Seeing this implies a recent change to shared.Project adding a field of unsupported type, or a custom MarshalJSON method returning an error.","solutions":["Read the appended err.Error() to identify the offending field.","Inspect recent changes to shared.Project for unsupported field types or faulty MarshalJSON implementations.","Fix the struct (supported type or proper MarshalJSON) and rebuild.","Add a serialization unit test for shared.Project."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"body, err := io.ReadAll(res.Body)\nif err != nil {\n\treturn err\n}\nif res.StatusCode == http.StatusInternalServerError && strings.Contains(string(body), \"Error marshalling projects\") {\n\treturn fmt.Errorf(\"server serialization bug: %s\", string(body))\n}\nvar projects []shared.Project\nreturn json.Unmarshal(body, &projects)","preventionTips":["Keep shared.Project JSON-safe; add a marshal unit test in CI.","Avoid custom MarshalJSON unless necessary; if present, make it total (never error on valid data).","Golden-file tests over sample projects list responses.","Version the shared package so client and server DTOs stay in sync."],"tags":["go","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-12T22:17:10.623Z"}