plandex-ai/plandex · error
Error marshalling default settings
Error message
Error marshalling default settings
What it means
After loading settings, GetDefaultSettingsHandler serializes them with json.Marshal. If marshaling fails (practically only when PlanSettings contains an unsupported value such as a bad channel, func, or a custom MarshalJSON that errors), the handler logs and returns 500 'Error marshalling default settings'.
Source
Thrown at app/server/handlers/settings.go:245
auth := Authenticate(w, r, true)
if auth == nil {
return
}
settings, err := db.GetOrgDefaultSettings(auth.OrgId)
if err != nil {
log.Println("Error getting default settings: ", err)
http.Error(w, "Error getting default settings", http.StatusInternalServerError)
return
}
bytes, err := json.Marshal(settings)
if err != nil {
log.Println("Error marshalling default settings: ", err)
http.Error(w, "Error marshalling default settings", http.StatusInternalServerError)
return
}
w.Write(bytes)
log.Println("GetDefaultSettingsHandler processed successfully")
}
func UpdateDefaultSettingsHandler(w http.ResponseWriter, r *http.Request) {
log.Println("Received request for UpdateDefaultSettingsHandler")
auth := Authenticate(w, r, true)
if auth == nil {
return
}
var req shared.UpdateSettingsRequestView on GitHub (pinned to e2d772072e)
Solutions
- Check the server log for 'Error marshalling default settings:' to identify the offending field
- Audit PlanSettings for unsupported field types (chan, func, cyclic pointers)
- Ensure server and plandex-shared versions are in sync
- Add json marshal tests over a freshly loaded PlanSettings fixture
- Redeploy after fixing the struct
Defensive patterns
Strategy: try-catch
Type guard
func marshalable(v any) (ok bool) {
defer func() { if r := recover(); r != nil { ok = false } }()
_, err := json.Marshal(v)
return err == nil
} Try / catch
const res = await api.getDefaultSettings();
try { JSON.parse(res.body); } catch { // treat as server serialization bug
reportBug('unparseable settings payload'); fallbackToCachedSettings();
} Prevention
- Add round-trip (marshal/unmarshal) tests for PlanSettings fixtures
- Keep server and shared-lib versions in lockstep
- Avoid unsupported field types (chan, func) in shared structs
- Validate settings payloads with CI before release
When it happens
Trigger: GET default settings succeeds at the DB layer but json.Marshal(settings) returns an error, typically from an invalid value inside the PlanSettings struct or a custom MarshalJSON implementation failing.
Common situations: A newly added field in PlanSettings has a type json can't encode; a custom marshaller panics/errs on nil nested pointers after a schema change; version mismatch between server and shared lib structs.
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 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/1644e9ea8a5d7198.
Report an issue: GitHub.