sipeed/picoclaw · error
Failed to serialize current config
Error message
Failed to serialize current config
What it means
Returned as a 500 from handlePatchConfig when json.Marshal of the freshly loaded config.Config struct fails. The struct just unmarshaled successfully, so this indicates an internal serialization anomaly rather than bad client input.
Solutions
- Retry the request; this is an internal error, not caused by the patch payload
- Inspect backend logs and custom MarshalJSON implementations on config types for bugs
- Report a bug with the current config file contents if reproducible
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at web/backend/api/config.go:157 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of sipeed/picoclaw@49183d7e8d (2026-08-15).
Data as JSON: /api/errors/684e2cacc0e61b3d.
Report an issue: GitHub.
Appendix: source
Thrown at web/backend/api/config.go:157
}
defer r.Body.Close()
// Validate the patch is valid JSON
var patch map[string]any
if err = json.Unmarshal(patchBody, &patch); err != nil {
http.Error(w, fmt.Sprintf("Invalid JSON: %v", err), http.StatusBadRequest)
return
}
// Load existing config and marshal to a map for merging
cfg, err := config.LoadConfig(h.configPath)
if err != nil {
http.Error(w, fmt.Sprintf("Failed to load config: %v", err), http.StatusInternalServerError)
return
}
existing, err := json.Marshal(cfg)
if err != nil {
http.Error(w, "Failed to serialize current config", http.StatusInternalServerError)
return
}
var base map[string]any
if err = json.Unmarshal(existing, &base); err != nil {
http.Error(w, "Failed to parse current config", http.StatusInternalServerError)
return
}
// Recursively merge patch into base
mergeMap(base, patch)
// When the patch updates dm_scope, the old derived dimensions from the
// base must be cleared so that ApplyDmScope() can re-derive them from
// the new dm_scope value. Otherwise the stale dimensions survive the
// merge and ApplyDmScope() exits early due to its precedence guard.
if sess, ok := base["session"].(map[string]any); ok {
if patchSess, patchHasSession := patch["session"].(map[string]any); patchHasSession {View on GitHub (pinned to 49183d7e8d)