ipfs/kubo · warning
key not found: %s
Error message
key not found: %s
What it means
`ipfs diag datastore get <key>` wraps datastore.ErrNotFound as 'key not found: <key>'. The requested key simply does not exist in the datastore; this is a user-input/lookup mismatch, distinguished from other read errors by errors.Is(err, datastore.ErrNotFound).
Source
Thrown at core/commands/diag.go:195
Options: []cmds.Option{
cmds.BoolOption(diagDatastoreHexOptionName, "Output hex dump instead of raw bytes"),
},
NoRemote: true,
PreRun: DaemonNotRunning,
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
ds, closer, err := openDiagDatastore(env)
if err != nil {
return err
}
defer closer()
keyStr := req.Arguments[0]
key := datastore.NewKey(keyStr)
val, err := ds.Get(req.Context, key)
if err != nil {
if errors.Is(err, datastore.ErrNotFound) {
return fmt.Errorf("key not found: %s", keyStr)
}
return fmt.Errorf("failed to read key: %w", err)
}
result := &diagDatastoreGetResult{
Key: keyStr,
Value: val,
}
if hexDump, _ := req.Options[diagDatastoreHexOptionName].(bool); hexDump {
result.HexDump = hex.Dump(val)
}
return cmds.EmitOnce(res, result)
},
Type: diagDatastoreGetResult{},
Encoders: cmds.EncoderMap{
cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, result *diagDatastoreGetResult) error {View on GitHub (pinned to 329838acdf)
Solutions
- Verify the exact key with `ipfs diag datastore ls` or by listing the datastore directly
- Check which datastore mount owns the key (main blockstore vs provider keystore mounts)
- Use `ipfs dag get`/`ipfs block get` for content, since block CIDs are stored under prefixed keys
Example fix
// before ipfs diag datastore get /blocks/wrongkey // error: key not found: /blocks/wrongkey // after ipfs diag datastore ls | grep <key-substring> ipfs diag datastore get /blocks/CIQ...correctmultihash
Defensive patterns
Strategy: validation
Validate before calling
val, err := ds.Get(ctx, key)
if errors.Is(err, datastore.ErrNotFound) { return fmt.Errorf("key not found: %s", keyStr) } Try / catch
err := diagDatastoreGet(key)
if err != nil && strings.Contains(err.Error(), "key not found") { listKeysAndRetry() } Prevention
- List keys (`ipfs diag datastore ls`) before fetching exact key strings
- Remember blockstore keys are prefixed (e.g. /blocks/<base32>), not raw CIDs
When it happens
Trigger: `ipfs diag datastore get <keyStr>` where ds.Get returns datastore.ErrNotFound for the given key.
Common situations: Guessing internal datastore key names; typos in key paths; keys from a different datastore/mount (keystore vs main datastore); keys garbage-collected away.
Related errors
- failed to find specified key
- failed to get config value: %q
- failed to open repo: %w
- failed to read key: %w
- reading new root block: %w
AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03).
Data as JSON: /api/errors/f8add8f99c853f4a.
Report an issue: GitHub.