{"record":{"id":"35e918c10158d83f","repo":"ipfs/kubo","slug":"failed-to-read-key-w","errorCode":null,"errorMessage":"failed to read key: %w","messagePattern":"failed to read key: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/diag.go","lineNumber":197,"sourceCode":"\t},\n\tNoRemote: true,\n\tPreRun:   DaemonNotRunning,\n\tRun: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {\n\t\tds, closer, err := openDiagDatastore(env)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tdefer closer()\n\n\t\tkeyStr := req.Arguments[0]\n\t\tkey := datastore.NewKey(keyStr)\n\n\t\tval, err := ds.Get(req.Context, key)\n\t\tif err != nil {\n\t\t\tif errors.Is(err, datastore.ErrNotFound) {\n\t\t\t\treturn fmt.Errorf(\"key not found: %s\", keyStr)\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"failed to read key: %w\", err)\n\t\t}\n\n\t\tresult := &diagDatastoreGetResult{\n\t\t\tKey:   keyStr,\n\t\t\tValue: val,\n\t\t}\n\n\t\tif hexDump, _ := req.Options[diagDatastoreHexOptionName].(bool); hexDump {\n\t\t\tresult.HexDump = hex.Dump(val)\n\t\t}\n\n\t\treturn cmds.EmitOnce(res, result)\n\t},\n\tType: diagDatastoreGetResult{},\n\tEncoders: cmds.EncoderMap{\n\t\tcmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, result *diagDatastoreGetResult) error {\n\t\t\tif result.HexDump != \"\" {\n\t\t\t\tfmt.Fprintf(w, \"Key: %s\\nHex Dump:\\n%s\", result.Key, result.HexDump)","sourceCodeStart":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/diag.go#L179-L215","documentation":"`ipfs diag datastore get <key>` wraps any datastore read error that is NOT ErrNotFound as 'failed to read key'. It signals real I/O or backend problems (corruption, permissions, backend failure) rather than a missing key.","triggerScenarios":"ds.Get(req.Context, key) returns an error other than datastore.ErrNotFound: disk I/O failure, permission denied, corrupt backend (badger/levelds/pebble) errors.","commonSituations":"Disk full or failing; wrong permissions on the repo directory; corrupted datastore backend after a crash; container filesystem issues.","solutions":["Check the wrapped underlying error in verbose output and daemon/diag logs","Verify disk space, permissions, and filesystem health on the repo directory","Repair or restore the datastore (backend-specific repair tools, or re-init and re-import from backups)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"err := diagDatastoreGet(key)\nif err != nil && strings.Contains(err.Error(), \"failed to read key\") { inspectUnderlying(err); checkDiskHealth() }","preventionTips":["Unwrap and log the underlying datastore error to identify the backend failure","Monitor disk space and permissions on the repo directory","Back up the repo and keep backend repair tools available"],"tags":["datastore","io","cli"],"backgroundTag":"datastore-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"}