{"record":{"id":"b154f32ae2322d35","repo":"sipeed/picoclaw","slug":"failed-to-serialize-merged-config","errorCode":null,"errorMessage":"Failed to serialize merged config","messagePattern":"Failed to serialize merged config","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"web/backend/api/config.go","lineNumber":191,"sourceCode":"\t// merge and ApplyDmScope() exits early due to its precedence guard.\n\tif sess, ok := base[\"session\"].(map[string]any); ok {\n\t\tif patchSess, patchHasSession := patch[\"session\"].(map[string]any); patchHasSession {\n\t\t\tif _, hasDmScope := patchSess[\"dm_scope\"]; hasDmScope {\n\t\t\t\tif _, hasDimsInPatch := patchSess[\"dimensions\"]; !hasDimsInPatch {\n\t\t\t\t\tdelete(sess, \"dimensions\")\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif err = normalizeChannelArrayFields(base); err != nil {\n\t\thttp.Error(w, fmt.Sprintf(\"Invalid channel array field: %v\", err), http.StatusBadRequest)\n\t\treturn\n\t}\n\n\t// Convert merged map back to Config struct\n\tmerged, err := json.Marshal(base)\n\tif err != nil {\n\t\thttp.Error(w, \"Failed to serialize merged config\", http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tvar newCfg config.Config\n\tif err = json.Unmarshal(merged, &newCfg); err != nil {\n\t\thttp.Error(w, fmt.Sprintf(\"Merged config is invalid: %v\", err), http.StatusBadRequest)\n\t\treturn\n\t}\n\tnewCfg.Session.ApplyDmScope()\n\tnewCfg.Session.DeriveDmScope()\n\n\t// Restore security fields (tokens/keys) from the loaded config before validation,\n\t// because private fields are lost during JSON round-trip.\n\tif err = newCfg.SecurityCopyFrom(h.configPath); err != nil {\n\t\thttp.Error(w, fmt.Sprintf(\"Failed to apply security config: %v\", err), http.StatusInternalServerError)\n\t\treturn\n\t}\n\tapplyConfigSecretsFromMap(&newCfg, base)","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/web/backend/api/config.go#L173-L209","documentation":"Error \"Failed to serialize merged config\" thrown in sipeed/picoclaw.","triggerScenarios":"Thrown at web/backend/api/config.go:191 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"49183d7e8daed0dba89ddbb6fcb60089401d9680","analyzedAt":"2026-08-15T21:55:41.315Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}