{"record":{"id":"9801fe540f0db9c4","repo":"plandex-ai/plandex","slug":"error-marshalling-plan-state","errorCode":null,"errorMessage":"Error marshalling plan state: ","messagePattern":"Error marshalling plan state: ","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"app/server/handlers/plans_changes.go","lineNumber":97,"sourceCode":"\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error getting current plan state: %v\", err)\n\t\t}\n\n\t\treturn nil\n\t})\n\n\tif err != nil {\n\t\tlog.Printf(\"Error getting current plan state: %v\\n\", err)\n\t\thttp.Error(w, \"Error getting current plan state: \"+err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tjsonBytes, err := json.Marshal(planState)\n\n\tif err != nil {\n\t\tlog.Printf(\"Error marshalling plan state: %v\\n\", err)\n\t\thttp.Error(w, \"Error marshalling plan state: \"+err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tlog.Println(\"Successfully retrieved current plan state\")\n\n\tw.Write(jsonBytes)\n}\n\nfunc ApplyPlanHandler(w http.ResponseWriter, r *http.Request) {\n\tlog.Println(\"Received request for ApplyPlanHandler\")\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\"]","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/handlers/plans_changes.go#L79-L115","documentation":"CurrentPlanHandler succeeded in building the CurrentPlanState but json.Marshal(planState) failed, so it returns 500 'Error marshalling plan state'. This is nearly impossible for well-formed state and usually indicates a custom MarshalJSON implementation failing on corrupt or unexpected data.","triggerScenarios":"CurrentPlanState (or a nested field with custom MarshalJSON, e.g. context/token data) contains values its marshaller cannot serialize; corrupted rows producing inconsistent state after an interrupted apply.","commonSituations":"Plan data written by a different (older/newer) server version with incompatible schema; NaN/invalid numeric values in custom serializers; corrupted plan repo after a crash mid-write.","solutions":["Check the server log for the marshal error message to identify which field failed","Upgrade/downgrade so client and server share the same plandex-shared version","Repair the plan by rejecting all pending changes and re-running, or restore from backup","If reproducible, file an issue with the marshal error — it indicates a serialization bug"],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"const res = await fetch(currentPlanUrl);\nif (res.status === 500 && (await res.text()).includes('Error marshalling plan state')) {\n  // serialization bug / corrupt state: resync shared versions, repair plan, report issue\n}","preventionTips":["Keep plandex-shared versions identical between client and server","Repair plans that survive a crash mid-apply (reject all changes)","Watch server logs for marshal errors and report reproducible ones","Restore plan from backup if state is persistently unserializable"],"tags":["json","serialization","plan-state"],"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"}