sipeed/picoclaw · error
failed to decode serialized config: %w
Error message
failed to decode serialized config: %w
What it means
validateConfigDocument re-unmarshals the bytes it just produced (helpers.go:149-152). Failing here means the in-memory config serialized into something encoding/json cannot read back — practically an invariant break, since the data was marshaled moments earlier from the same structs. Not reachable through normal CLI usage.
Source
Thrown at cmd/picoclaw/internal/mcp/helpers.go:151
}
clone.Tools = cfg.Tools
clone.Tools.MCP = cfg.Tools.MCP
clone.Tools.MCP.Servers = make(map[string]config.MCPServerConfig, len(cfg.Tools.MCP.Servers))
for name, server := range cfg.Tools.MCP.Servers {
if server.Type != "" {
server.Type = config.NormalizeMCPTransportType(server.Type)
}
clone.Tools.MCP.Servers[name] = server
}
return &clone
}
func validateConfigDocument(data []byte) error {
var instance map[string]any
if err := json.Unmarshal(data, &instance); err != nil {
return fmt.Errorf("failed to decode serialized config: %w", err)
}
schema, err := loadMCPConfigSchema()
if err != nil {
return fmt.Errorf("failed to load MCP config schema: %w", err)
}
if err := schema.Validate(instance); err != nil {
return fmt.Errorf("config validation failed: %w", err)
}
return nil
}
func loadMCPConfigSchema() (*jsonschema.Resolved, error) {
mcpConfigSchemaOnce.Do(func() {
var schema jsonschema.Schema
if err := json.Unmarshal([]byte(mcpConfigSchemaJSON), &schema); err != nil {View on GitHub (pinned to 49183d7e8d)
Solutions
- Report upstream as a bug with the config contents; there is no user-level remediation
- If you added a custom MarshalJSON, make it emit strict RFC 8259 JSON (no NaN/Infinity) and round-trip test it
Defensive patterns
Strategy: try-catch
Try / catch
if err := saveValidatedConfig(cfg); err != nil {
if strings.Contains(err.Error(), "failed to decode serialized config") {
// invariant break inside picoclaw itself — collect a bug report
// with the config contents; no caller-side remediation exists
return fmt.Errorf("internal picoclaw bug (config round-trip): %w", err)
}
return err
} Prevention
- If you maintain a fork, round-trip test any custom MarshalJSON implementations
- Treat this message as 'report upstream', not as a config problem
When it happens
Trigger: Custom MarshalJSON on a config type emitting invalid JSON (e.g. bare NaN/Infinity via hand-rolled marshaling); memory corruption. Plain encoding/json cannot produce this.
Common situations: Contributors adding custom marshalers to config types.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- failed to serialize config: %w
- marshal result: %w
- conversation not found for %s after ingest
- marshal request: %w
- parse response: %w
AI-assisted analysis of sipeed/picoclaw@49183d7e8d (2026-08-15).
Data as JSON: /api/errors/f4a82bf8f53e5657.
Report an issue: GitHub.