sipeed/picoclaw · error

migrateV0ToV1: expected version 0, got

Error message

migrateV0ToV1: expected version 0, got %v

What it means

Guard in migrateV0ToV1: the migration step expected the raw config map's version to be 0 (legacy config without a version field) but found another value, meaning the migration chain was called out of order or the map was already migrated.

Solutions

  1. Let LoadConfig run the full migration chain from the config's actual version instead of calling migrateV0ToV1 directly
  2. Check that the config file's version field was not hand-edited
  3. Restore an earlier backup of the config and let migration run normally
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pkg/config/migration.go:180 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/4f633262411b8c86. Report an issue: GitHub.

Appendix: source

Thrown at pkg/config/migration.go:180

	switch val := v.(type) {
	case int:
		return val == expected
	case float64:
		return val == float64(expected)
	case nil:
		return expected == 0
	default:
		return false
	}
}

// migrateV0ToV1 converts a V0 (legacy, no version field) config JSON to V1 format:
//  1. Migrates legacy providers to model_list
//  2. Migrates agents.defaults.model → agents.defaults.model_name
//  3. Sets version to 1
func migrateV0ToV1(m map[string]any) error {
	if !compareInt(m["version"], 0) {
		return fmt.Errorf("migrateV0ToV1: expected version 0, got %v", m["version"])
	}

	migrateLegacyAgentDefaultsModel(m)

	// Migrate legacy providers to model_list if no model_list exists
	if _, hasModelList := m["model_list"]; !hasModelList {
		if providers, hasProviders := m["providers"]; hasProviders {
			if provMap, ok := providers.(map[string]any); ok && !isProvidersMapEmpty(provMap) {
				// Extract user's provider and model from agents.defaults
				userProvider := ""
				userModel := ""
				if agents, ok := m["agents"].(map[string]any); ok {
					if defaults, ok := agents["defaults"].(map[string]any); ok {
						if v, ok := defaults["provider"].(string); ok {
							userProvider = v
						}
						// Check both model_name (new) and model (old) fields
						if v, ok := defaults["model_name"].(string); ok && v != "" {

View on GitHub (pinned to 49183d7e8d)