sipeed/picoclaw · error
Merged config is invalid
Error message
Merged config is invalid: %v
What it means
Returned as a 400 from handlePatchConfig when the merged config map cannot be unmarshaled into config.Config: the combination of stored config and patch produces a structurally invalid config (wrong types for known fields). The %v carries the decode error.
Solutions
- Read the %v detail to find the field whose type conflicts with the Config schema
- Correct the field's type in the PATCH body
- Patch fields one at a time to isolate the offending key
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at web/backend/api/config.go:197 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/72aa84abe1d33fe7.
Report an issue: GitHub.
Appendix: source
Thrown at web/backend/api/config.go:197
}
}
}
}
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)
if errs := validateConfig(&newCfg); len(errs) > 0 {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusBadRequest)
json.NewEncoder(w).Encode(map[string]any{
"status": "validation_error",View on GitHub (pinned to 49183d7e8d)