sipeed/picoclaw · error

backup before reset

Error message

backup before reset: %w

What it means

Wraps a MakeBackup failure inside ResetToDefaults: before overwriting config.json with defaults, a dated backup of the current config must be taken; if that fails, reset is aborted to avoid destroying the user's configuration without a copy.

Solutions

  1. Fix the underlying backup failure (permissions, disk space) reported by the wrapped error
  2. Back up config.json and security.yml manually, then retry the reset
  3. Export the current config via the web UI before resetting
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at pkg/config/config.go:1769 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/6ecc719ea0e06686. Report an issue: GitHub.

Appendix: source

Thrown at pkg/config/config.go:1769

// Note: Multiple entries with the same model_name are allowed for load balancing.
func (c *Config) ValidateModelList() error {
	for i := range c.ModelList {
		if err := c.ModelList[i].Validate(); err != nil {
			return fmt.Errorf("model_list[%d]: %w", i, err)
		}
	}
	return nil
}

func (c *Config) SecurityCopyFrom(path string) error {
	return loadSecurityConfig(c, securityPath(path))
}

// ResetToDefaults backs up the current config, creates a default config,
// preserves security credentials from the existing config, and saves it.
func ResetToDefaults(configPath string) error {
	if err := MakeBackup(configPath); err != nil {
		return fmt.Errorf("backup before reset: %w", err)
	}
	cfg := DefaultConfig()
	cfg.Session.ApplyDmScope()
	cfg.Session.DeriveDmScope()
	if err := cfg.SecurityCopyFrom(configPath); err != nil {
		logger.WarnF("could not preserve security config", map[string]any{"error": err})
	}
	return SaveConfig(configPath, cfg)
}

func expandMultiKeyModels(models []*ModelConfig) []*ModelConfig {
	var expanded []*ModelConfig

	for _, m := range models {
		keys := m.APIKeys.Values()

		// Single key or no keys: keep as-is
		if len(keys) <= 1 {

View on GitHub (pinned to 49183d7e8d)