{"record":{"id":"5b9d36263b4dc651","repo":"ipfs/kubo","slug":"no-key-named-s-was-found","errorCode":null,"errorMessage":"no key named %s was found","messagePattern":"no key named (.+?) was found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/coreapi/key.go","lineNumber":195,"sourceCode":"\toptions, err := caopts.KeyRenameOptions(opts...)\n\tif err != nil {\n\t\treturn nil, false, err\n\t}\n\tspan.SetAttributes(attribute.Bool(\"force\", options.Force))\n\n\tks := api.repo.Keystore()\n\n\tif oldName == \"self\" {\n\t\treturn nil, false, errors.New(\"cannot rename key with name 'self'\")\n\t}\n\n\tif newName == \"self\" {\n\t\treturn nil, false, errors.New(\"cannot overwrite key with name 'self'\")\n\t}\n\n\toldKey, err := ks.Get(oldName)\n\tif err != nil {\n\t\treturn nil, false, fmt.Errorf(\"no key named %s was found\", oldName)\n\t}\n\n\tpubKey := oldKey.GetPublic()\n\n\tpid, err := peer.IDFromPublicKey(pubKey)\n\tif err != nil {\n\t\treturn nil, false, err\n\t}\n\n\t// This is important, because future code will delete key `oldName`\n\t// even if it is the same as newName.\n\tif newName == oldName {\n\t\tk, err := newKey(oldName, pid)\n\t\treturn k, false, err\n\t}\n\n\toverwrite := false\n\tif options.Force {","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/coreapi/key.go#L177-L213","documentation":"Rename looks up the source key with Keystore().Get(oldName). If the lookup fails — the key does not exist, or the keystore read errors — Rename reports 'no key named X was found' and does not overwrite.","triggerScenarios":"KeyAPI.Rename(ctx, oldName, newName, opts...) where oldName is not present in the keystore (or is not 'self', whose lookup is not attempted), e.g. `ipfs key rename missing self-target`.","commonSituations":"Renaming a key that was already removed; typo in the source name in a script; keys listed from a different node/IPFS_PATH than the one serving the API; using a generated name pattern that no longer matches.","solutions":["Run `ipfs key list` (or KeyAPI.List) and confirm the exact source key name.","Fix the oldName argument (typos, casing, whitespace).","Verify you are connected to the node whose keystore actually contains the key (correct IPFS_PATH / --api).","Create the key first with `ipfs key gen` if it never existed."],"exampleFix":"// before\nfound, overwritten, err := api.Key().Rename(ctx, \"myke\", \"renamed\")\n// after\nkeys, _ := api.Key().List(ctx)\nif keyExists(keys, \"mykey\") {\n    found, overwritten, err = api.Key().Rename(ctx, \"mykey\", \"renamed\")\n}","handlingStrategy":"validation","validationCode":"keys, err := api.Key().List(ctx)\nif err != nil { return err }\nif !slices.ContainsFunc(keys, func(k coreiface.Key) bool { return k.Name() == oldName }) {\n    return fmt.Errorf(\"key %q does not exist on this node\", oldName)\n}","typeGuard":null,"tryCatchPattern":"ok, _, err := api.Key().Rename(ctx, oldName, newName, opts...)\nif err != nil && strings.Contains(err.Error(), \"was found\") {\n    return fmt.Errorf(\"key %q missing; list keys to confirm exact name\", oldName)\n}","preventionTips":["Always list keys to confirm exact names before renaming","Ensure the CLI/API targets the node/IPFS_PATH holding the key","Handle double-rename races by re-listing after failures"],"tags":["keystore","keys","not-found"],"backgroundTag":"key-not-found","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"}