sipeed/picoclaw · error

Failed to reset config

Error message

Failed to reset config: %v

What it means

Returned as a 500 from handleResetConfig when config.SaveConfig fails while writing the factory-default configuration back to disk. The reset did not complete; API keys and security credentials were meant to be preserved but persistence failed.

Solutions

  1. Check backend logs for the underlying SaveConfig error
  2. Verify disk space and write permissions on the config path
  3. Retry the reset; if it keeps failing, restore the config file manually
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at web/backend/api/config.go:239 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of sipeed/picoclaw@49183d7e8d (2026-08-15). Data as JSON: /api/errors/4e4a86f89ad9fa8b. Report an issue: GitHub.

Appendix: source

Thrown at web/backend/api/config.go:239

	if err := config.SaveConfig(h.configPath, &newCfg); err != nil {
		http.Error(w, fmt.Sprintf("Failed to save config: %v", err), http.StatusInternalServerError)
		return
	}

	h.applyRuntimeLogLevel()
	logger.Infof("configuration updated successfully")

	w.Header().Set("Content-Type", "application/json")
	json.NewEncoder(w).Encode(map[string]string{"status": "ok"})
}

// handleResetConfig resets the configuration to factory defaults.
// API keys and security credentials are preserved.
//
//	POST /api/config/reset
func (h *Handler) handleResetConfig(w http.ResponseWriter, r *http.Request) {
	if err := config.ResetToDefaults(h.configPath); err != nil {
		http.Error(w, fmt.Sprintf("Failed to reset config: %v", err), http.StatusInternalServerError)
		return
	}

	h.applyRuntimeLogLevel()
	logger.Infof("configuration reset to factory defaults")

	// Restart gateway if running
	status := h.gatewayStatusData()
	gatewayStatus, _ := status["gateway_status"].(string)
	if gatewayStatus == "running" {
		if _, err := h.RestartGateway(); err != nil {
			logger.ErrorF("failed to restart gateway after config reset", map[string]any{"error": err.Error()})
		}
	}

	w.Header().Set("Content-Type", "application/json")
	json.NewEncoder(w).Encode(map[string]string{"status": "ok"})
}

View on GitHub (pinned to 49183d7e8d)