{"record":{"id":"e951808358975af4","repo":"ipfs/kubo","slug":"failed-to-query-datastore-w","errorCode":null,"errorMessage":"failed to query datastore: %w","messagePattern":"failed to query datastore: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/diag.go","lineNumber":299,"sourceCode":"\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\tprefix := req.Arguments[0]\n\n\t\tq := query.Query{\n\t\t\tPrefix:   prefix,\n\t\t\tKeysOnly: true,\n\t\t}\n\n\t\tresults, err := ds.Query(req.Context, q)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to query datastore: %w\", err)\n\t\t}\n\t\tdefer results.Close()\n\n\t\tvar count int64\n\t\tfor result := range results.Next() {\n\t\t\tif result.Error != nil {\n\t\t\t\treturn fmt.Errorf(\"query error: %w\", result.Error)\n\t\t\t}\n\t\t\tcount++\n\t\t}\n\n\t\treturn cmds.EmitOnce(res, &diagDatastoreCountResult{\n\t\t\tPrefix: prefix,\n\t\t\tCount:  count,\n\t\t})\n\t},\n\tType: diagDatastoreCountResult{},\n\tEncoders: cmds.EncoderMap{","sourceCodeStart":281,"sourceCodeEnd":317,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/diag.go#L281-L317","documentation":"'ipfs diag ds count' failed to start a prefix query over the debugging datastore. %w is the underlying ds.Query error; typical causes are a locked datastore (daemon running) or storage-level failure. Debugging/testing command only.","triggerScenarios":"Thrown at core/commands/diag.go:299 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the daemon is not running so the datastore is not locked","Check the repo directory permissions and disk health","Retry after the underlying storage issue is resolved"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}