sipeed/picoclaw · error
Failed to serialize merged config
Error message
Failed to serialize merged config
What it means
Returned as a 400 from handlePatchConfig when normalizeChannelArrayFields rejects the merged (existing + patch) config map: a channel field that must be an array is malformed in either the patch or the stored config. The %v names the offending field.
Solutions
- Read the error detail to find which channel field is malformed and whether it came from the patch or stored config
- Fix the channel field in the PATCH body to be a valid array
- If the stored config is corrupt, repair it on disk before patching
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at web/backend/api/config.go:191 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/b154f32ae2322d35.
Report an issue: GitHub.
Appendix: source
Thrown at web/backend/api/config.go:191
// 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 {
if _, hasDmScope := patchSess["dm_scope"]; hasDmScope {
if _, hasDimsInPatch := patchSess["dimensions"]; !hasDimsInPatch {
delete(sess, "dimensions")
}
}
}
}
if err = normalizeChannelArrayFields(base); err != nil {
http.Error(w, fmt.Sprintf("Invalid channel array field: %v", err), http.StatusBadRequest)
return
}
// Convert merged map back to Config struct
merged, err := json.Marshal(base)
if err != nil {
http.Error(w, "Failed to serialize merged config", http.StatusInternalServerError)
return
}
var newCfg config.Config
if err = json.Unmarshal(merged, &newCfg); err != nil {
http.Error(w, fmt.Sprintf("Merged config is invalid: %v", err), http.StatusBadRequest)
return
}
newCfg.Session.ApplyDmScope()
newCfg.Session.DeriveDmScope()
// Restore security fields (tokens/keys) from the loaded config before validation,
// because private fields are lost during JSON round-trip.
if err = newCfg.SecurityCopyFrom(h.configPath); err != nil {
http.Error(w, fmt.Sprintf("Failed to apply security config: %v", err), http.StatusInternalServerError)
return
}
applyConfigSecretsFromMap(&newCfg, base)View on GitHub (pinned to 49183d7e8d)