{"record":{"id":"4f633262411b8c86","repo":"sipeed/picoclaw","slug":"migratev0tov1-expected-version-0-got-v","errorCode":null,"errorMessage":"migrateV0ToV1: expected version 0, got %v","messagePattern":"migrateV0ToV1: expected version 0, got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/config/migration.go","lineNumber":180,"sourceCode":"\tswitch val := v.(type) {\n\tcase int:\n\t\treturn val == expected\n\tcase float64:\n\t\treturn val == float64(expected)\n\tcase nil:\n\t\treturn expected == 0\n\tdefault:\n\t\treturn false\n\t}\n}\n\n// migrateV0ToV1 converts a V0 (legacy, no version field) config JSON to V1 format:\n//  1. Migrates legacy providers to model_list\n//  2. Migrates agents.defaults.model → agents.defaults.model_name\n//  3. Sets version to 1\nfunc migrateV0ToV1(m map[string]any) error {\n\tif !compareInt(m[\"version\"], 0) {\n\t\treturn fmt.Errorf(\"migrateV0ToV1: expected version 0, got %v\", m[\"version\"])\n\t}\n\n\tmigrateLegacyAgentDefaultsModel(m)\n\n\t// Migrate legacy providers to model_list if no model_list exists\n\tif _, hasModelList := m[\"model_list\"]; !hasModelList {\n\t\tif providers, hasProviders := m[\"providers\"]; hasProviders {\n\t\t\tif provMap, ok := providers.(map[string]any); ok && !isProvidersMapEmpty(provMap) {\n\t\t\t\t// Extract user's provider and model from agents.defaults\n\t\t\t\tuserProvider := \"\"\n\t\t\t\tuserModel := \"\"\n\t\t\t\tif agents, ok := m[\"agents\"].(map[string]any); ok {\n\t\t\t\t\tif defaults, ok := agents[\"defaults\"].(map[string]any); ok {\n\t\t\t\t\t\tif v, ok := defaults[\"provider\"].(string); ok {\n\t\t\t\t\t\t\tuserProvider = v\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// Check both model_name (new) and model (old) fields\n\t\t\t\t\t\tif v, ok := defaults[\"model_name\"].(string); ok && v != \"\" {","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/pkg/config/migration.go#L162-L198","documentation":"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.","triggerScenarios":"Thrown at pkg/config/migration.go:180 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Let LoadConfig run the full migration chain from the config's actual version instead of calling migrateV0ToV1 directly","Check that the config file's version field was not hand-edited","Restore an earlier backup of the config and let migration run normally"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"49183d7e8daed0dba89ddbb6fcb60089401d9680","analyzedAt":"2026-08-15T21:55:41.315Z","contentChangedAt":"2026-08-15T21:55:41.315Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}