{"record":{"id":"d62ee27929c38ec1","repo":"unionlabs/union","slug":"expected-validator-not-found","errorCode":null,"errorMessage":"expected validator, not found","messagePattern":"expected validator, not found","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"uniond/app/export.go","lineNumber":207,"sourceCode":"\t\t\tpanic(err)\n\t\t}\n\t\treturn false\n\t})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// Iterate through validators by power descending, reset bond heights, and\n\t// update bond intra-tx counters.\n\tstore := ctx.KVStore(app.GetKey(stakingtypes.StoreKey))\n\titer := storetypes.KVStoreReversePrefixIterator(store, stakingtypes.ValidatorsKey)\n\tcounter := int16(0)\n\n\tfor ; iter.Valid(); iter.Next() {\n\t\taddr := sdk.ValAddress(stakingtypes.AddressFromValidatorsKey(iter.Key()))\n\t\tvalidator, err := app.StakingKeeper.GetValidator(ctx, addr)\n\t\tif err != nil {\n\t\t\tpanic(\"expected validator, not found\")\n\t\t}\n\n\t\tvalidator.UnbondingHeight = 0\n\t\tif applyAllowedAddrs && !allowedAddrsMap[addr.String()] {\n\t\t\tvalidator.Jailed = true\n\t\t}\n\n\t\tif err := app.StakingKeeper.SetValidator(ctx, validator); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tcounter++\n\t}\n\n\tif err := iter.Close(); err != nil {\n\t\tapp.Logger().Error(\"error while closing the key-value store reverse prefix iterator: \", err)\n\t\treturn\n\t}\n","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/unionlabs/union/blob/031785bb6dc6b957c624e62bc64c184409c97d7b/uniond/app/export.go#L189-L225","documentation":"Export iterates the validators-by-power index (reverse prefix iterator over ValidatorsKey) and re-fetches each validator via GetValidator. If the index yields an address whose validator record cannot be read back, the staking store is internally inconsistent and export panics — a defensive check copied from simapp ExportGenesis. On healthy state the two keys cannot disagree.","triggerScenarios":"Corrupted IAVL/multi-store where the power index and the validators key set diverge; a data directory from an incompatible store version or an interrupted migration; a node home tampered with or hit by disk-level corruption.","commonSituations":"Swapping uniond binaries across store versions without running migrations, hardware/disk corruption, copying a data dir mid-write, prune/snapshot tooling bugs.","solutions":["Restore the node home from a known-good snapshot or synced copy and re-run export","Confirm binary/store compatibility — start the intended uniond version so migrations apply before exporting","If persistent, dump the staking store and diff validators-by-power keys against main validator records to identify the orphaned entry","If state cannot be reconciled, re-sync the chain rather than exporting corrupted genesis"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# Never export from the live home dir; run against a snapshot copy\nuniond export --home /backup/union-copy --for-zero-height > genesis.json 2> export.err || cat export.err","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Take periodic data-dir snapshots so export always runs on a verified copy","Never point a new uniond binary at an old store version without the proper migration path","Investigate app-hash mismatches immediately — they precede detectable state divergence","Keep the uniond version that matches your data dir recorded alongside backups"],"tags":["cosmos-sdk","staking","state-corruption","genesis-export","panic","golang"],"backgroundTag":null,"analyzedSha":"031785bb6dc6b957c624e62bc64c184409c97d7b","analyzedAt":"2026-08-16T06:24:09.996Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}