plandex-ai/plandex · error
Error marshalling branches:
Error message
Error marshalling branches:
What it means
A 500 returned when json.Marshal fails on the map[string]*shared.Branch result before writing the response. Practically this is rare — it only fails if Branch.ToApi() produced a value json cannot encode (e.g. an unsupported type like a channel, func, or a cyclic structure).
Source
Thrown at app/server/handlers/plans_crud.go:651
var branches []db.Branch
err = db.Conn.Select(&branches, query, queryArgs...)
if err != nil {
log.Printf("Error getting branches: %v\n", err)
http.Error(w, "Error getting branches: "+err.Error(), http.StatusInternalServerError)
return
}
res := map[string]*shared.Branch{}
for _, branch := range branches {
res[branch.PlanId] = branch.ToApi()
}
bytes, err := json.Marshal(res)
if err != nil {
log.Printf("Error marshalling branches: %v\n", err)
http.Error(w, "Error marshalling branches: "+err.Error(), http.StatusInternalServerError)
return
}
log.Println("Successfully processed GetCurrentBranchByPlanIdHandler request")
w.Write(bytes)
}
View on GitHub (pinned to e2d772072e)
Solutions
- Read the logged '%v' detail to identify the offending field/type
- Ensure all fields on shared.Branch are JSON-serializable (no channels, funcs, or cycles)
- If a custom MarshalJSON was added to Branch, fix or remove it
- Retry the request — transient corruption of in-memory state clears on restart
Defensive patterns
Strategy: try-catch
Try / catch
try {
const res = await api.getCurrentBranchByPlanId(projectId, body);
} catch (err) {
if (err.status === 500 && String(err.message).startsWith('Error marshalling branches:')) {
// server-side serialization bug: report with server log detail
console.error('Response serialization failed on server; likely version mismatch', err.message);
return null;
}
throw err;
} Prevention
- Keep client and server versions of shared.Branch in sync
- Never add non-serializable fields (channels, funcs, cycles) to shared types
- If forking, test ToApi() output with json.Marshal in CI
- This is essentially never a client-side problem — treat as a server bug
When it happens
Trigger: A shared.Branch field of unmarshallable type (channel/func/cycle) introduced by a code change or corrupt DB row feeding ToApi().
Common situations: Custom builds with modified Branch/ToApi types; a plugin or fork adding non-serializable fields; corrupted rows producing unexpected values in custom field types with broken MarshalJSON.
Related errors
- Error marshalling branches:
- Error marshalling response:
- Error marshalling invites:
- Error marshalling response
- Error marshalling contexts:
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/3baf6e56374258fe.
Report an issue: GitHub.