{"record":{"id":"d138b2acdfa045c2","repo":"sipeed/picoclaw","slug":"failed-to-parse-current-config","errorCode":null,"errorMessage":"Failed to parse current config","messagePattern":"Failed to parse current config","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"web/backend/api/config.go","lineNumber":163,"sourceCode":"\t\thttp.Error(w, fmt.Sprintf(\"Invalid JSON: %v\", err), http.StatusBadRequest)\n\t\treturn\n\t}\n\n\t// Load existing config and marshal to a map for merging\n\tcfg, err := config.LoadConfig(h.configPath)\n\tif err != nil {\n\t\thttp.Error(w, fmt.Sprintf(\"Failed to load config: %v\", err), http.StatusInternalServerError)\n\t\treturn\n\t}\n\texisting, err := json.Marshal(cfg)\n\tif err != nil {\n\t\thttp.Error(w, \"Failed to serialize current config\", http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tvar base map[string]any\n\tif err = json.Unmarshal(existing, &base); err != nil {\n\t\thttp.Error(w, \"Failed to parse current config\", http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\t// Recursively merge patch into base\n\tmergeMap(base, patch)\n\n\t// When the patch updates dm_scope, the old derived dimensions from the\n\t// base must be cleared so that ApplyDmScope() can re-derive them from\n\t// the new dm_scope value. Otherwise the stale dimensions survive the\n\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}","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/web/backend/api/config.go#L145-L181","documentation":"Returned as a 500 from handlePatchConfig when the just-marshaled existing config bytes cannot be unmarshaled back into map[string]any for JSON merging. Since the bytes came from json.Marshal, this signals an internal inconsistency rather than client error.","triggerScenarios":"Thrown at web/backend/api/config.go:163 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the request; the failure is internal to the merge step","Inspect the on-disk config for values that marshal/unmarshal asymmetrically (e.g. large numbers, invalid UTF-8)","Report a bug with the config file if reproducible"],"exampleFix":null,"handlingStrategy":"fallback","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"}