{"record":{"id":"4002675a55742c3e","repo":"wtfutil/wtf","slug":"could-not-get-disk-usage-w","errorCode":null,"errorMessage":"could not get disk usage: %w","messagePattern":"could not get disk usage: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"modules/docker/client.go","lineNumber":22,"sourceCode":"\t\"context\"\n\t\"fmt\"\n\t\"sort\"\n\t\"strings\"\n\n\t\"github.com/docker/docker/api/types\"\n\t\"github.com/docker/docker/api/types/container\"\n\t\"github.com/dustin/go-humanize\"\n)\n\nfunc (widget *Widget) getSystemInfo() string {\n\tinfo, err := widget.cli.Info(context.Background())\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not get docker system info: %w\", err).Error()\n\t}\n\n\tdiskUsage, err := widget.cli.DiskUsage(context.Background(), types.DiskUsageOptions{})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not get disk usage: %w\", err).Error()\n\t}\n\n\tvar duContainer int64\n\tfor _, c := range diskUsage.Containers {\n\t\tduContainer += c.SizeRw\n\t}\n\tvar duImg int64\n\tfor _, im := range diskUsage.Images {\n\t\tduImg += im.Size\n\t}\n\tvar duVol int64\n\tfor _, v := range diskUsage.Volumes {\n\t\tduVol += v.UsageData.Size\n\t}\n\n\tsysInfo := []struct {\n\t\tname  string\n\t\tvalue string","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/wtfutil/wtf/blob/bb838c1ccb0f0f3223690df44afdec663d622881/modules/docker/client.go#L4-L40","documentation":"getSystemInfo calls cli.DiskUsage(ctx, types.DiskUsageOptions{}); a failure is stringified into the widget buffer as \"could not get disk usage\". The Docker /system/df call failed even though Info may have succeeded, so the daemon connection works but the disk-usage API call does not.","triggerScenarios":"cli.DiskUsage fails: daemon version older than the DiskUsageOptions API expects, connection dropped between calls, daemon busy/OOM, or API version negotiation mismatch between the docker client library and the daemon.","commonSituations":"Docker Engine upgraded/downgraded while the app pins a specific API version, very large daemon making /system/df time out, or permission-restricted endpoints on remote daemons.","solutions":["Run docker system df manually to confirm the daemon supports and completes the call.","Let the client negotiate the API version (remove explicit version pinning in client.NewClientWithOpts).","Retry the call; transient daemon load can cause one-off failures.","Update the docker/docker client library to match your Engine version."],"exampleFix":"// before\ndiskUsage, err := widget.cli.DiskUsage(context.Background(), types.DiskUsageOptions{})\nif err != nil {\n\treturn fmt.Errorf(\"could not get disk usage: %w\", err).Error()\n}\n// after\ndiskUsage, err := widget.cli.DiskUsage(context.Background(), types.DiskUsageOptions{})\nif err != nil {\n\treturn fmt.Errorf(\"could not get disk usage: %w\", err).Error() // fallback: show container stats only\n}","handlingStrategy":"fallback","validationCode":"// Verify daemon supports disk usage before calling\nout, err := exec.Command(\"docker\", \"system\", \"df\", \"--format\", \"json\").Output()\nif err != nil {\n\t// skip DiskUsage section of the widget\n}","typeGuard":"func isDiskUsageError(err error) bool {\n\treturn err != nil && strings.Contains(err.Error(), \"disk usage\")\n}","tryCatchPattern":"diskUsage, err := widget.cli.DiskUsage(ctx, types.DiskUsageOptions{})\nif err != nil {\n\twidget.displayBuffer = \"disk usage unavailable: \" + err.Error()\n\treturn // fall back to container-only display\n}","preventionTips":["Keep the docker client library and Docker Engine versions aligned.","Avoid pinning an explicit API version; let the client negotiate.","Handle DiskUsage failure independently so the rest of the widget still renders."],"tags":["docker","disk-usage","api-version","go"],"backgroundTag":"docker-daemon-unreachable","analyzedSha":"bb838c1ccb0f0f3223690df44afdec663d622881","analyzedAt":"2026-09-03T17:02:45.030Z","contentChangedAt":"2026-09-03T17:02:45.030Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}