{"record":{"id":"c44deb7b76f253ea","repo":"sipeed/picoclaw","slug":"failed-to-apply-security-config-v","errorCode":null,"errorMessage":"Failed to apply security config: %v","messagePattern":"Failed to apply security config: (.+?)","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"web/backend/api/config.go","lineNumber":89,"sourceCode":"\t\thttp.Error(w, \"Failed to normalize config payload\", http.StatusBadRequest)\n\t\treturn\n\t}\n\tvar cfg config.Config\n\tif err = json.Unmarshal(normalizedBody, &cfg); err != nil {\n\t\thttp.Error(w, fmt.Sprintf(\"Invalid JSON: %v\", err), http.StatusBadRequest)\n\t\treturn\n\t}\n\tcfg.Session.ApplyDmScope()\n\tcfg.Session.DeriveDmScope()\n\tif execAllowRemoteOmitted(body) {\n\t\tcfg.Tools.Exec.AllowRemote = config.DefaultConfig().Tools.Exec.AllowRemote\n\t}\n\n\t// Load existing config and copy security credentials before validation,\n\t// so that security-managed fields (e.g. pico token) are available.\n\terr = cfg.SecurityCopyFrom(h.configPath)\n\tif 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(&cfg, raw)\n\n\tif errs := validateConfig(&cfg); 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\",\n\t\t\t\"errors\": errs,\n\t\t})\n\t\treturn\n\t}\n\n\tif err := config.SaveConfig(h.configPath, &cfg); err != nil {\n\t\thttp.Error(w, fmt.Sprintf(\"Failed to save config: %v\", err), http.StatusInternalServerError)\n\t\treturn\n\t}","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/web/backend/api/config.go#L71-L107","documentation":"Error \"Failed to apply security config: %v\" thrown in sipeed/picoclaw.","triggerScenarios":"Thrown at web/backend/api/config.go:89 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"}