{"record":{"id":"ec2e5f4796531737","repo":"vxcontrol/pentagi","slug":"list-command-failed-for-s-with-exit-code-d-s","errorCode":null,"errorMessage":"list command failed for '%s' with exit code %d: %s","messagePattern":"list command failed for '(.+?)' with exit code (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/pkg/docker/client.go","lineNumber":1011,"sourceCode":"\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\n\t// to stat are carried in Failures — the find exec already proved the container\n\t// alive, so a live directory degrades rather than 500s even if every entry failed.\n\tif err := ctx.Err(); err != nil {\n\t\treturn ContainerDirListing{}, fmt.Errorf(\"listing container directory '%s': %w\", dirPath, err)\n\t}\n\n\tlisting := ContainerDirListing{Files: stats, Truncated: truncated}\n\tfor _, f := range failures {","sourceCodeStart":993,"sourceCodeEnd":1029,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/docker/client.go#L993-L1029","documentation":"The `find <dir> -maxdepth 1 -mindepth 1 ! -name .* -print0` command executed inside the container exited non-zero. The output captured so far is embedded in the message to aid diagnosis. Common exit codes: 1 = find error (e.g. directory vanished, permission), 125 = docker daemon failed to run the exec, 126 = binary not executable, 127 = command (find) not found.","triggerScenarios":"dirPath was deleted between the initial stat and the exec; the directory lacks read permission; the image has no `find` binary (exit 127); daemon failed to start the process (exit 125).","commonSituations":"Temp dirs cleaned by the workload mid-listing; minimal/distroless images without find; permission-restricted directories (chmod 000); SELinux/AppArmor blocking exec inside hardened containers.","solutions":["Read the embedded output/exit code: 127 means install `find` (busybox) in the image","Re-check the directory exists and is readable (`ls -ld <dir>` inside the container) and retry","If permissions are the cause, run the exec as root or relax the directory mode","Check for security modules (AppArmor/SELinux) denying exec in the container"],"exampleFix":"// before: distroless image has no find -> exit 127\nFROM gcr.io/distroless/base\n// after: use an image with a shell toolchain, or install busybox\nFROM alpine:3 # provides busybox find","handlingStrategy":"validation","validationCode":"// ensure `find` exists and the dir is readable inside the container\nexec := []string{\"sh\", \"-c\", \"command -v find >/dev/null && test -r \" + dir + \" && test -d \" + dir}\nif err := runInContainer(ctx, containerID, exec); err != nil {\n    return fmt.Errorf(\"dir %s not listable in %s: %w\", dir, containerID, err)\n}","typeGuard":null,"tryCatchPattern":"listing, err := client.ListContainerDir(ctx, containerID, dir)\nif err != nil {\n    var exitErr interface{ ExitCode() string }\n    if code := extractExitCode(err); code == 127 {\n        return fmt.Errorf(\"image lacks find binary; install busybox\")\n    }\n    return err\n}","preventionTips":["Build images with busybox or coreutils so `find` is present","Verify target directories exist and are readable before listing","Don't delete/rename directories concurrently with listing","Check AppArmor/SELinux profiles allow exec in the container"],"tags":["docker","exec","exit-code","find"],"backgroundTag":"docker-exec-nonzero-exit","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}