{"record":{"id":"ab76793aa94e0ea2","repo":"ipfs/kubo","slug":"keystore-name-for-back-up-cannot-be-named-self","errorCode":null,"errorMessage":"keystore name for back up cannot be named 'self'","messagePattern":"keystore name for back up cannot be named 'self'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/keystore.go","lineNumber":765,"sourceCode":"\t},\n\tArguments: []cmds.Argument{},\n\tOptions: []cmds.Option{\n\t\tcmds.StringOption(oldKeyOptionName, \"o\", \"Keystore name to use for backing up your existing identity\"),\n\t\tcmds.StringOption(keyStoreTypeOptionName, \"t\", \"type of the key to create: rsa, ed25519, secp256k1\").WithDefault(keyStoreAlgorithmDefault),\n\t\tcmds.IntOption(keyStoreSizeOptionName, \"s\", \"size of the key to generate\"),\n\t},\n\tNoRemote: true,\n\tPreRun:   DaemonNotRunning,\n\tRun: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {\n\t\tcctx := env.(*oldcmds.Context)\n\t\tnBitsForKeypair, nBitsGiven := req.Options[keyStoreSizeOptionName].(int)\n\t\talgorithm, _ := req.Options[keyStoreTypeOptionName].(string)\n\t\toldKey, ok := req.Options[oldKeyOptionName].(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"keystore name for backing up old key must be provided\")\n\t\t}\n\t\tif oldKey == \"self\" {\n\t\t\treturn fmt.Errorf(\"keystore name for back up cannot be named 'self'\")\n\t\t}\n\t\treturn doRotate(os.Stdout, cctx.ConfigRoot, oldKey, algorithm, nBitsForKeypair, nBitsGiven)\n\t},\n}\n\nfunc doRotate(out io.Writer, repoRoot string, oldKey string, algorithm string, nBitsForKeypair int, nBitsGiven bool) error {\n\t// Open repo\n\trepo, err := fsrepo.Open(repoRoot)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"opening repo (%v)\", err)\n\t}\n\tdefer repo.Close()\n\n\t// Read config file from repo\n\tcfg, err := repo.Config()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"reading config from repo (%v)\", err)\n\t}","sourceCodeStart":747,"sourceCodeEnd":783,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/keystore.go#L747-L783","documentation":"The key rotate command stores the old identity key inside the keystore. 'self' is reserved as the logical name for the node's active identity, so using it as the backup name would collide with / shadow the very key being replaced. The Run function explicitly rejects oldKey == \"self\" before calling doRotate.","triggerScenarios":"Running `ipfs key rotate --old-key=self` (or --old-key with value 'self' in any case variation passed exactly as 'self').","commonSituations":"Users intuitively thinking 'self' is the right backup name since it backs up the self key; scripts templating the current identity name into the backup slot.","solutions":["Choose a different backup name, e.g. `--old-key=backup-2024` or `--old-key=previous-self`","If you want the old key deleted entirely, note rotate always keeps a backup — there is no 'self' overwrite path","After rotation, retrieve the old key with `ipfs key export <name>` if needed"],"exampleFix":"// before\nipfs key rotate --old-key=self\n// after\nipfs key rotate --old-key=previous-identity","handlingStrategy":"validation","validationCode":"if oldKey == \"self\" {\n    return errors.New(\"--old-key must not be 'self'; choose a backup name like old-self\")\n}","typeGuard":"func validBackupName(name string) bool {\n    return name != \"\" && name != \"self\"\n}","tryCatchPattern":null,"preventionTips":["Never use reserved names ('self') as keystore backup names","Use timestamped backup names like rotate-backup-2024-01","Check `ipfs key list` to avoid collisions"],"tags":["cli","keystore","reserved-name"],"backgroundTag":"reserved-name-conflict","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"}