{"record":{"id":"72aa84abe1d33fe7","repo":"sipeed/picoclaw","slug":"merged-config-is-invalid-v","errorCode":null,"errorMessage":"Merged config is invalid: %v","messagePattern":"Merged config is invalid: (.+?)","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"web/backend/api/config.go","lineNumber":197,"sourceCode":"\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)\n\n\tif errs := validateConfig(&newCfg); len(errs) > 0 {\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\tjson.NewEncoder(w).Encode(map[string]any{\n\t\t\t\"status\": \"validation_error\",","sourceCodeStart":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/web/backend/api/config.go#L179-L215","documentation":"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.","triggerScenarios":"Thrown at web/backend/api/config.go:197 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"49183d7e8daed0dba89ddbb6fcb60089401d9680","analyzedAt":"2026-08-15T21:55:41.315Z","contentChangedAt":"2026-08-15T21:55:41.315Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}