wtfutil/wtf · warning
could not get disk usage: %w
Error message
could not get disk usage: %w
What it means
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.
Source
Thrown at modules/docker/client.go:22
"context"
"fmt"
"sort"
"strings"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/dustin/go-humanize"
)
func (widget *Widget) getSystemInfo() string {
info, err := widget.cli.Info(context.Background())
if err != nil {
return fmt.Errorf("could not get docker system info: %w", err).Error()
}
diskUsage, err := widget.cli.DiskUsage(context.Background(), types.DiskUsageOptions{})
if err != nil {
return fmt.Errorf("could not get disk usage: %w", err).Error()
}
var duContainer int64
for _, c := range diskUsage.Containers {
duContainer += c.SizeRw
}
var duImg int64
for _, im := range diskUsage.Images {
duImg += im.Size
}
var duVol int64
for _, v := range diskUsage.Volumes {
duVol += v.UsageData.Size
}
sysInfo := []struct {
name string
value stringView on GitHub (pinned to bb838c1ccb)
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.
Example fix
// before
diskUsage, err := widget.cli.DiskUsage(context.Background(), types.DiskUsageOptions{})
if err != nil {
return fmt.Errorf("could not get disk usage: %w", err).Error()
}
// after
diskUsage, err := widget.cli.DiskUsage(context.Background(), types.DiskUsageOptions{})
if err != nil {
return fmt.Errorf("could not get disk usage: %w", err).Error() // fallback: show container stats only
} Defensive patterns
Strategy: fallback
Validate before calling
// Verify daemon supports disk usage before calling
out, err := exec.Command("docker", "system", "df", "--format", "json").Output()
if err != nil {
// skip DiskUsage section of the widget
} Type guard
func isDiskUsageError(err error) bool {
return err != nil && strings.Contains(err.Error(), "disk usage")
} Try / catch
diskUsage, err := widget.cli.DiskUsage(ctx, types.DiskUsageOptions{})
if err != nil {
widget.displayBuffer = "disk usage unavailable: " + err.Error()
return // fall back to container-only display
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- could not get docker system info: %w
- could not get container list: %w
- could not create client: %w
- invalid app index selected
- cannot expand user-specific home dir
AI-assisted analysis of wtfutil/wtf@bb838c1ccb (2026-09-03).
Data as JSON: /api/errors/4002675a55742c3e.
Report an issue: GitHub.