sipeed/picoclaw · error

Failed to serialize merged config

Error message

Failed to serialize merged config

What it means

Error "Failed to serialize merged config" thrown in sipeed/picoclaw.

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)

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.