{"record":{"id":"1bd046d969128e98","repo":"hasura/graphql-engine","slug":"parsing-migration-version-w","errorCode":null,"errorMessage":"parsing migration version: %w","messagePattern":"parsing migration version: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/internal/statestore/migrations/catalogstate.go","lineNumber":117,"sourceCode":"\nfunc (m *CatalogStateStore) PrepareMigrationsStateStore(_ string) error {\n\treturn nil\n}\n\nfunc (m *CatalogStateStore) GetVersions(database string) (map[uint64]bool, error) {\n\tvar op errors.Op = \"migrations.CatalogStateStore.GetVersions\"\n\n\tstate, err := m.getCLIState()\n\tif err != nil {\n\t\treturn nil, errors.E(op, err)\n\t}\n\n\tversions := map[uint64]bool{}\n\n\tfor version, dirty := range state.GetMigrationsByDatabase(database) {\n\t\tparsedVersion, err := strconv.ParseUint(version, 10, 64)\n\t\tif err != nil {\n\t\t\treturn nil, errors.E(op, fmt.Errorf(\"parsing migration version: %w\", err))\n\t\t}\n\n\t\tversions[parsedVersion] = dirty\n\t}\n\n\treturn versions, nil\n}\n\nfunc (m *CatalogStateStore) SetVersions(database string, versions []statestore.Version) error {\n\tvar op errors.Op = \"migrations.CatalogStateStore.SetVersions\"\n\n\tstate, err := m.getCLIState()\n\tif err != nil {\n\t\treturn errors.E(op, err)\n\t}\n\n\tfor _, v := range versions {\n\t\tversionString := strconv.FormatInt(v.Version, 10)","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/internal/statestore/migrations/catalogstate.go#L99-L135","documentation":"The catalog state store (migrations state kept in hdb_catalog as JSON) contains a migration version key that is not a valid base-10 uint64; strconv.ParseUint fails when building the version map.","triggerScenarios":"Calling GetVersions on a CLICatalogState/migration state store where the server-stored migration state JSON has a non-numeric key (e.g. a named migration like '01_init' or corrupted/manual entry) instead of a numeric version string.","commonSituations":"Hand-edited hdb_catalog state, server bugs writing state, or tooling that stored named/timestamp-style versions incompatible with the numeric version contract.","solutions":["Inspect the migration state in hdb_catalog (e.g. the migrations table / cli_state rows) for non-numeric version keys","Fix or remove the offending entries so all versions are numeric strings","Retry the operation (migrate status / update-project-v3)","If caused by a server bug, upgrade the Hasura server and re-sync state"],"exampleFix":"-- before: state contains version \"01_init\"\nSELECT * FROM hdb_catalog.hdb_version;\n-- after: keep only numeric versions\nDELETE FROM hdb_catalog.hdb_catalog_migration WHERE version !~ '^[0-9]+$';","handlingStrategy":"validation","validationCode":"for v := range versions {\n    if _, err := strconv.ParseUint(v, 10, 64); err != nil {\n        return fmt.Errorf(\"non-numeric migration version %q in state; clean hdb_catalog first\", v)\n    }\n}","typeGuard":"func isNumericVersion(s string) bool { _, err := strconv.ParseUint(s, 10, 64); return err == nil }","tryCatchPattern":"if _, err := store.GetVersions(db); err != nil {\n    if strings.Contains(err.Error(), \"parsing migration version\") { /* query state table, remove non-numeric keys, retry */ }\n}","preventionTips":["Never hand-edit migration state JSON to non-numeric keys","Use only numeric migration version prefixes"],"tags":["data-corruption","migrations","state-store","strconv"],"backgroundTag":"invalid-migration-version","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}