sipeed/picoclaw · error

Failed to apply security config

Error message

Failed to apply security config: %v

What it means

Returned as a 500 from handleUpdateConfig when SecurityCopyFrom fails to load the existing config on disk and copy security-managed credentials (e.g. the pico token) into the new config before validation. The config file or its path is unreadable or corrupt.

Solutions

  1. Check backend logs for the underlying SecurityCopyFrom error
  2. Verify the config file at the server's config path exists and is readable
  3. Fix or restore the on-disk config file, then retry the update
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at web/backend/api/config.go:89 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/c44deb7b76f253ea. Report an issue: GitHub.

Appendix: source

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

		http.Error(w, "Failed to normalize config payload", http.StatusBadRequest)
		return
	}
	var cfg config.Config
	if err = json.Unmarshal(normalizedBody, &cfg); err != nil {
		http.Error(w, fmt.Sprintf("Invalid JSON: %v", err), http.StatusBadRequest)
		return
	}
	cfg.Session.ApplyDmScope()
	cfg.Session.DeriveDmScope()
	if execAllowRemoteOmitted(body) {
		cfg.Tools.Exec.AllowRemote = config.DefaultConfig().Tools.Exec.AllowRemote
	}

	// Load existing config and copy security credentials before validation,
	// so that security-managed fields (e.g. pico token) are available.
	err = cfg.SecurityCopyFrom(h.configPath)
	if err != nil {
		http.Error(w, fmt.Sprintf("Failed to apply security config: %v", err), http.StatusInternalServerError)
		return
	}
	applyConfigSecretsFromMap(&cfg, raw)

	if errs := validateConfig(&cfg); len(errs) > 0 {
		w.Header().Set("Content-Type", "application/json")
		w.WriteHeader(http.StatusBadRequest)
		json.NewEncoder(w).Encode(map[string]any{
			"status": "validation_error",
			"errors": errs,
		})
		return
	}

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

View on GitHub (pinned to 49183d7e8d)