{"record":{"id":"ce5c6cdfff09a15e","repo":"ipfs/kubo","slug":"query-error-w","errorCode":null,"errorMessage":"query error: %w","messagePattern":"query error: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/diag.go","lineNumber":306,"sourceCode":"\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{\n\t\tcmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, result *diagDatastoreCountResult) error {\n\t\t\t_, err := fmt.Fprintf(w, \"%d\\n\", result.Count)\n\t\t\treturn err\n\t\t}),\n\t},\n}\n","sourceCodeStart":288,"sourceCodeEnd":324,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/diag.go#L288-L324","documentation":"'ipfs diag ds count': an individual result from the ongoing datastore query iteration returned an Error. %w is that per-entry error; counting stops and the partial count is discarded. Usually a storage read failure mid-iteration. Debugging/testing command only.","triggerScenarios":"Thrown at core/commands/diag.go:306 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Re-run the count; transient read errors may not recur","Investigate the wrapped error for datastore corruption","Check disk health on the repo volume"],"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"}