{"record":{"id":"c125a4d1da7c8bf4","repo":"ipfs/kubo","slug":"cannot-list-keys-in-keystore-w","errorCode":null,"errorMessage":"cannot list keys in keystore: %w","messagePattern":"cannot list keys in keystore: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/coreapi/key.go","lineNumber":136,"sourceCode":"\t\treturn nil, err\n\t}\n\n\tpid, err := peer.IDFromPublicKey(pk)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn newKey(name, pid)\n}\n\n// List returns a list keys stored in keystore.\nfunc (api *KeyAPI) List(ctx context.Context) ([]coreiface.Key, error) {\n\t_, span := tracing.Span(ctx, \"CoreAPI.KeyAPI\", \"List\")\n\tdefer span.End()\n\n\tkeys, err := api.repo.Keystore().List()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"cannot list keys in keystore: %w\", err)\n\t}\n\n\tsort.Strings(keys)\n\n\tout := make([]coreiface.Key, 1, len(keys)+1)\n\tout[0], err = newKey(\"self\", api.identity)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfor _, k := range keys {\n\t\tprivKey, err := api.repo.Keystore().Get(k)\n\t\tif err != nil {\n\t\t\tlog.Errorf(\"cannot get key from keystore: %s\", err)\n\t\t\tcontinue\n\t\t}\n\n\t\tpubKey := privKey.GetPublic()","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/coreapi/key.go#L118-L154","documentation":"KeyAPI.List starts by enumerating all keystore entries. If repo.Keystore().List() fails (underlying datastore error, keystore file unreadable/corrupt), the error is wrapped with 'cannot list keys in keystore'.","triggerScenarios":"Calling KeyAPI.List(ctx) (or `ipfs key list`) when the repo keystore cannot be read: permissions changed on repo/keystore, disk I/O failure, corrupted keystore datastore.","commonSituations":"Running the node/API under a different user than the repo owner (permission denied); read-only filesystem mount; partial migration leaving the keystore inconsistent.","solutions":["Check the wrapped %w cause for the underlying datastore/OS error.","Fix file permissions on $IPFS_PATH/keystore so the daemon user can read it.","Verify the repo datastore health and disk space.","Restore the keystore from backup if entries are corrupted."],"exampleFix":"// before\nsudo -u otheruser ipfs key list\n// after\nchown -R ipfs:ipfs ~/.ipfs/keystore && sudo -u ipfs ipfs key list","handlingStrategy":"try-catch","validationCode":"if _, err := os.Stat(filepath.Join(repoPath, \"keystore\")); err != nil {\n    return fmt.Errorf(\"keystore directory unreadable: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"keys, err := api.Key().List(ctx)\nif err != nil {\n    var perr *fs.PathError\n    if errors.As(err, &perr) {\n        // permission or IO problem on keystore: fix perms/disk before retry\n    }\n    return fmt.Errorf(\"cannot list keys in keystore: %w\", err)\n}","preventionTips":["Run the daemon as the repo owner so keystore permissions match","Keep $IPFS_PATH/keystore on a writable, healthy filesystem","Back up the keystore directory and monitor disk errors"],"tags":["keystore","keys","datastore","io"],"backgroundTag":"keystore-read-failed","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"}