ipfs/kubo · error

no key named %s was found

Error message

no key named %s was found

What it means

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.

Source

Thrown at core/coreapi/key.go:195

	options, err := caopts.KeyRenameOptions(opts...)
	if err != nil {
		return nil, false, err
	}
	span.SetAttributes(attribute.Bool("force", options.Force))

	ks := api.repo.Keystore()

	if oldName == "self" {
		return nil, false, errors.New("cannot rename key with name 'self'")
	}

	if newName == "self" {
		return nil, false, errors.New("cannot overwrite key with name 'self'")
	}

	oldKey, err := ks.Get(oldName)
	if err != nil {
		return nil, false, fmt.Errorf("no key named %s was found", oldName)
	}

	pubKey := oldKey.GetPublic()

	pid, err := peer.IDFromPublicKey(pubKey)
	if err != nil {
		return nil, false, err
	}

	// This is important, because future code will delete key `oldName`
	// even if it is the same as newName.
	if newName == oldName {
		k, err := newKey(oldName, pid)
		return k, false, err
	}

	overwrite := false
	if options.Force {

View on GitHub (pinned to 329838acdf)

Solutions

  1. Run `ipfs key list` (or KeyAPI.List) and confirm the exact source key name.
  2. Fix the oldName argument (typos, casing, whitespace).
  3. Verify you are connected to the node whose keystore actually contains the key (correct IPFS_PATH / --api).
  4. Create the key first with `ipfs key gen` if it never existed.

Example fix

// before
found, overwritten, err := api.Key().Rename(ctx, "myke", "renamed")
// after
keys, _ := api.Key().List(ctx)
if keyExists(keys, "mykey") {
    found, overwritten, err = api.Key().Rename(ctx, "mykey", "renamed")
}
Defensive patterns

Strategy: validation

Validate before calling

keys, err := api.Key().List(ctx)
if err != nil { return err }
if !slices.ContainsFunc(keys, func(k coreiface.Key) bool { return k.Name() == oldName }) {
    return fmt.Errorf("key %q does not exist on this node", oldName)
}

Try / catch

ok, _, err := api.Key().Rename(ctx, oldName, newName, opts...)
if err != nil && strings.Contains(err.Error(), "was found") {
    return fmt.Errorf("key %q missing; list keys to confirm exact name", oldName)
}

Prevention

When it happens

Trigger: 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`.

Common situations: 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.

Related errors


AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03). Data as JSON: /api/errors/5b9d36263b4dc651. Report an issue: GitHub.