{"record":{"id":"c40605988da5d0bf","repo":"vxcontrol/pentagi","slug":"failed-to-read-list-output-for-s-w","errorCode":null,"errorMessage":"failed to read list output for '%s': %w","messagePattern":"failed to read list output for '(.+?)': %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/pkg/docker/client.go","lineNumber":1003,"sourceCode":"\t// including a \\n that is part of a filename — corrupting the name. Without a\n\t// TTY the exec stream is multiplexed and demuxed below.\n\tcreateResp, err := dc.ContainerExecCreate(ctx, containerID, client.ExecCreateOptions{\n\t\tCmd:          []string{\"find\", dirPath, \"-maxdepth\", \"1\", \"-mindepth\", \"1\", \"!\", \"-name\", \".*\", \"-print0\"},\n\t\tAttachStdout: true,\n\t\tAttachStderr: true,\n\t})\n\tif err != nil {\n\t\treturn ContainerDirListing{}, fmt.Errorf(\"failed to create list exec for '%s': %w\", dirPath, err)\n\t}\n\n\tresp, err := dc.ContainerExecAttach(ctx, createResp.ID, client.ExecAttachOptions{})\n\tif err != nil {\n\t\treturn ContainerDirListing{}, fmt.Errorf(\"failed to attach list exec for '%s': %w\", dirPath, err)\n\t}\n\toutput, readErr := demuxExecStdout(resp.Reader, maxListStdoutBytes)\n\tresp.Close()\n\tif readErr != nil {\n\t\treturn ContainerDirListing{}, fmt.Errorf(\"failed to read list output for '%s': %w\", dirPath, readErr)\n\t}\n\n\tinspect, err := dc.ContainerExecInspect(ctx, createResp.ID)\n\tif err != nil {\n\t\treturn ContainerDirListing{}, fmt.Errorf(\"failed to inspect list exec for '%s': %w\", dirPath, err)\n\t}\n\tif inspect.ExitCode != 0 {\n\t\treturn ContainerDirListing{}, fmt.Errorf(\"list command failed for '%s' with exit code %d: %s\", dirPath, inspect.ExitCode, string(output))\n\t}\n\n\tentryPaths, truncated := parseFindEntries(output)\n\n\tstats, failures := statContainerEntries(ctx, entryPaths, containerListWorkers, func(ctx context.Context, entryPath string) (container.PathStat, error) {\n\t\treturn dc.ContainerStatPath(ctx, containerID, entryPath)\n\t})\n\n\t// A cancelled context is a directory-level fault (the client is gone), not a\n\t// partial listing, so surface it as an error. Entries that individually failed","sourceCodeStart":985,"sourceCodeEnd":1021,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/docker/client.go#L985-L1021","documentation":"demuxExecStdout reads the multiplexed exec stream and its error is wrapped with this message. Failures include a truncated frame (ErrUnexpectedEOF mid-header/frame), stdout exceeding the byte cap, or a daemon-injected systemerr frame. In all cases the listing is considered incomplete and is discarded rather than served partially.","triggerScenarios":"The exec stream ends mid-frame (connection reset, daemon killed the stream, container OOM-killed while find was writing), the directory listing produces more than maxListStdoutBytes of stdout, or Docker injects a systemerr frame (stream id 3).","commonSituations":"Listing a huge directory (node_modules, /usr, /proc) blowing the output cap; container killed mid-exec; flaky connection to a remote Docker daemon; sandboxed workload deliberately flooding output.","solutions":["List a narrower subdirectory instead of a huge parent (reduce output below the cap)","Retry the listing if the cause was a transient stream reset","Check why the container exited mid-exec (OOM, kill signal) via `docker inspect`","If the cap is legitimately too small for your workload, raise maxListStdoutBytes"],"exampleFix":"// before: giant dir overflows the cap\nlisting, err := dc.ListContainerDir(ctx, id, \"/\")\n// after: list the intended subtree\nlisting, err := dc.ListContainerDir(ctx, id, \"/workspace/src\")","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"listing, err := client.ListContainerDir(ctx, containerID, dir)\nif err != nil {\n    if strings.Contains(err.Error(), \"failed to read list output\") {\n        // stream read failed: retry or narrow the directory\n        return retryListing(ctx, containerID, dir)\n    }\n    return err\n}","preventionTips":["List narrow directories rather than huge trees","Keep containers alive and un-OOM'd during listings","Avoid flaky proxies between client and daemon","Tune maxListStdoutBytes to expected workload"],"tags":["docker","stream","output-limit"],"backgroundTag":"docker-exec-stream-truncated","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}