{"record":{"id":"531a35e589cdbfc3","repo":"ipfs/kubo","slug":"key-export-expects-repo-version-d-but-found-d","errorCode":null,"errorMessage":"key export expects repo version (%d) but found (%d)","messagePattern":"key export expects repo version \\((.+?)\\) but found \\((.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/keystore.go","lineNumber":209,"sourceCode":"\tRun: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {\n\t\tname := req.Arguments[0]\n\n\t\tif name == \"self\" {\n\t\t\treturn fmt.Errorf(\"cannot export key with name 'self'\")\n\t\t}\n\n\t\tcfgRoot, err := cmdenv.GetConfigRoot(env)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// Check repo version, and error out if not matching\n\t\tver, err := migrations.RepoVersion(cfgRoot)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif ver != fsrepo.RepoVersion {\n\t\t\treturn fmt.Errorf(\"key export expects repo version (%d) but found (%d)\", fsrepo.RepoVersion, ver)\n\t\t}\n\n\t\t// Export is read-only: safe to read it without acquiring repo lock\n\t\t// (this makes export work when ipfs daemon is already running)\n\t\tksp := filepath.Join(cfgRoot, \"keystore\")\n\t\tks, err := keystore.NewFSKeystore(ksp)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tsk, err := ks.Get(name)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"key with name '%s' doesn't exist\", name)\n\t\t}\n\n\t\texportFormat, _ := req.Options[keyFormatOptionName].(string)\n\t\tvar formattedKey []byte\n\t\tswitch exportFormat {","sourceCodeStart":191,"sourceCodeEnd":227,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/keystore.go#L191-L227","documentation":"Repo-version compatibility check in `ipfs key export`: the on-disk repository version at the config root (read via migrations.RepoVersion) differs from the fsrepo.RepoVersion this binary supports. Export reads the keystore files directly without the repo lock, so it must not run against a repo written by a different (older or newer) Kubo version whose keystore layout may differ.","triggerScenarios":"Thrown at core/commands/keystore.go:209 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Run the matching Kubo version that created the repository","Run ipfs daemon (or the migration tool) once to migrate the repo to this binary's version","Point IPFS_PATH at the correct repository if the wrong one was targeted"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"329838acdfafae224582930457efe80aa217afc0","analyzedAt":"2026-09-03T18:30:52.135Z","contentChangedAt":"2026-09-03T18:30:52.135Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}