plandex-ai/plandex · error
Error marshalling plan state:
Error message
Error marshalling plan state:
What it means
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.
Source
Thrown at app/server/handlers/plans_changes.go:97
if err != nil {
return fmt.Errorf("error getting current plan state: %v", err)
}
return nil
})
if err != nil {
log.Printf("Error getting current plan state: %v\n", err)
http.Error(w, "Error getting current plan state: "+err.Error(), http.StatusInternalServerError)
return
}
jsonBytes, err := json.Marshal(planState)
if err != nil {
log.Printf("Error marshalling plan state: %v\n", err)
http.Error(w, "Error marshalling plan state: "+err.Error(), http.StatusInternalServerError)
return
}
log.Println("Successfully retrieved current plan state")
w.Write(jsonBytes)
}
func ApplyPlanHandler(w http.ResponseWriter, r *http.Request) {
log.Println("Received request for ApplyPlanHandler")
auth := Authenticate(w, r, true)
if auth == nil {
return
}
vars := mux.Vars(r)
planId := vars["planId"]View on GitHub (pinned to e2d772072e)
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
Example fix
null
Defensive patterns
Strategy: try-catch
Validate before calling
null
Type guard
null
Try / catch
const res = await fetch(currentPlanUrl);
if (res.status === 500 && (await res.text()).includes('Error marshalling plan state')) {
// serialization bug / corrupt state: resync shared versions, repair plan, report issue
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: json.Marshal / "failed to marshal" errors in Go: why "unsupported type" happens and how to fix it — this error's family across 22 libraries.
Related errors
- error marshalling auth header: %v
- error marshalling models: %v
- error marshalling account credentials: %v
- error marshalling model pack: %v
- error marshalling current plan: %v
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/9801fe540f0db9c4.
Report an issue: GitHub.