sipeed/picoclaw · error

failed to read config

Error message

failed to read config: %w

What it means

Raised in loadConfigMap when os.ReadFile on config.json fails with an error other than not-exist (permission denied, I/O error, path is a directory). A missing file is treated as 'no config' and returns defaults instead; only real read failures produce this error.

Solutions

  1. Check permissions on config.json and its parent directory
  2. Verify the path points to a regular file, not a directory
  3. Check disk/filesystem health if I/O errors persist
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at pkg/config/migration.go:411 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/72bfd73abdae929a. Report an issue: GitHub.

Appendix: source

Thrown at pkg/config/migration.go:411

			}
		}

		m["channel_list"] = channels
	}

	m["version"] = CurrentVersion

	return nil
}

func loadConfigMap(path string) (map[string]any, error) {
	var m1, m2 map[string]any
	data, err := os.ReadFile(path)
	if err != nil {
		if os.IsNotExist(err) {
			return m1, nil
		}
		return nil, fmt.Errorf("failed to read config: %w", err)
	}
	if err = json.Unmarshal(data, &m1); err != nil {
		return nil, wrapJSONError(data, err, "config.json")
	}
	secPath := securityPath(path)
	data, err = os.ReadFile(secPath)
	if err != nil {
		if os.IsNotExist(err) {
			return m1, nil
		}
		return nil, fmt.Errorf("failed to read security config: %w", err)
	}
	if err = yaml.Unmarshal(data, &m2); err != nil {
		return nil, fmt.Errorf("failed to parse security config: %w", err)
	}
	if m2["web"] != nil || m2["skills"] != nil {
		m3 := make(map[string]any)
		if m2["web"] != nil {

View on GitHub (pinned to 49183d7e8d)