vxcontrol/pentagi · error

failed to inspect list exec for '%s': %w

Error message

failed to inspect list exec for '%s': %w

What it means

After reading the exec output, ListContainerDir calls ContainerExecInspect to learn the exec's exit code. This error wraps a failure of that inspect call — the exec's status could not be retrieved. Note this is the API call failing, not the `find` command failing (that is errorIndex 284).

Source

Thrown at backend/pkg/docker/client.go:1008

		AttachStderr: true,
	})
	if err != nil {
		return ContainerDirListing{}, fmt.Errorf("failed to create list exec for '%s': %w", dirPath, err)
	}

	resp, err := dc.ContainerExecAttach(ctx, createResp.ID, client.ExecAttachOptions{})
	if err != nil {
		return ContainerDirListing{}, fmt.Errorf("failed to attach list exec for '%s': %w", dirPath, err)
	}
	output, readErr := demuxExecStdout(resp.Reader, maxListStdoutBytes)
	resp.Close()
	if readErr != nil {
		return ContainerDirListing{}, fmt.Errorf("failed to read list output for '%s': %w", dirPath, readErr)
	}

	inspect, err := dc.ContainerExecInspect(ctx, createResp.ID)
	if err != nil {
		return ContainerDirListing{}, fmt.Errorf("failed to inspect list exec for '%s': %w", dirPath, err)
	}
	if inspect.ExitCode != 0 {
		return ContainerDirListing{}, fmt.Errorf("list command failed for '%s' with exit code %d: %s", dirPath, inspect.ExitCode, string(output))
	}

	entryPaths, truncated := parseFindEntries(output)

	stats, failures := statContainerEntries(ctx, entryPaths, containerListWorkers, func(ctx context.Context, entryPath string) (container.PathStat, error) {
		return dc.ContainerStatPath(ctx, containerID, entryPath)
	})

	// A cancelled context is a directory-level fault (the client is gone), not a
	// partial listing, so surface it as an error. Entries that individually failed
	// to stat are carried in Failures — the find exec already proved the container
	// alive, so a live directory degrades rather than 500s even if every entry failed.
	if err := ctx.Err(); err != nil {
		return ContainerDirListing{}, fmt.Errorf("listing container directory '%s': %w", dirPath, err)
	}

View on GitHub (pinned to ea665308ba)

Solutions

  1. Re-run the listing on a container that stays alive for the duration of the call
  2. Avoid `--rm`/auto-removal racing the inspect by keeping the container running until results are consumed
  3. Check daemon connectivity and retry on transient errors
  4. Verify the exec ID is valid — do not reuse exec IDs across calls
Defensive patterns

Strategy: retry

Try / catch

listing, err := client.ListContainerDir(ctx, containerID, dir)
if err != nil && strings.Contains(err.Error(), "failed to inspect list exec") {
    // exec record vanished: retry on a container guaranteed to persist
    listing, err = client.ListContainerDir(ctx, containerID, dir)
}

Prevention

When it happens

Trigger: ContainerExecInspect(ctx, createResp.ID) errors because the exec record was garbage-collected/removed, the container was removed (Docker purges execs with the container), or the daemon connection failed.

Common situations: Container removed immediately after its command finished (short-lived containers, auto-remove flag); daemon restart; remote daemon connectivity loss between attach and inspect.

Related errors


AI-assisted analysis of vxcontrol/pentagi@ea665308ba (2026-09-01). Data as JSON: /api/errors/56527b450b45ad15. Report an issue: GitHub.