{"record":{"id":"4e4a86f89ad9fa8b","repo":"sipeed/picoclaw","slug":"failed-to-reset-config-v","errorCode":null,"errorMessage":"Failed to reset config: %v","messagePattern":"Failed to reset config: (.+?)","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"web/backend/api/config.go","lineNumber":239,"sourceCode":"\tif err := config.SaveConfig(h.configPath, &newCfg); err != nil {\n\t\thttp.Error(w, fmt.Sprintf(\"Failed to save config: %v\", err), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\th.applyRuntimeLogLevel()\n\tlogger.Infof(\"configuration updated successfully\")\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tjson.NewEncoder(w).Encode(map[string]string{\"status\": \"ok\"})\n}\n\n// handleResetConfig resets the configuration to factory defaults.\n// API keys and security credentials are preserved.\n//\n//\tPOST /api/config/reset\nfunc (h *Handler) handleResetConfig(w http.ResponseWriter, r *http.Request) {\n\tif err := config.ResetToDefaults(h.configPath); err != nil {\n\t\thttp.Error(w, fmt.Sprintf(\"Failed to reset config: %v\", err), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\th.applyRuntimeLogLevel()\n\tlogger.Infof(\"configuration reset to factory defaults\")\n\n\t// Restart gateway if running\n\tstatus := h.gatewayStatusData()\n\tgatewayStatus, _ := status[\"gateway_status\"].(string)\n\tif gatewayStatus == \"running\" {\n\t\tif _, err := h.RestartGateway(); err != nil {\n\t\t\tlogger.ErrorF(\"failed to restart gateway after config reset\", map[string]any{\"error\": err.Error()})\n\t\t}\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tjson.NewEncoder(w).Encode(map[string]string{\"status\": \"ok\"})\n}","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/web/backend/api/config.go#L221-L257","documentation":"Error \"Failed to reset config: %v\" thrown in sipeed/picoclaw.","triggerScenarios":"Thrown at web/backend/api/config.go:239 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"}