vxcontrol/pentagi · error

failed to inspect file-check exec: %w

Error message

failed to inspect file-check exec: %w

What it means

This error wraps a failure from ContainerExecInspect, which is called after reading the exec output to learn the exit code of the file-check command. The inspect API call to the Docker daemon failed, so the executor cannot determine whether the command succeeded. This is a Docker API-level failure, not a command failure (a nonzero command exit produces the separate exit-code error).

Source

Thrown at backend/pkg/tools/tools.go:676

		AttachStdout: true,
		AttachStderr: true,
	})
	if err != nil {
		return nil, fmt.Errorf("failed to create file-check exec: %w", err)
	}

	resp, err := fte.docker.ContainerExecAttach(ctx, createResp.ID, client.ExecAttachOptions{})
	if err != nil {
		return nil, fmt.Errorf("failed to attach file-check exec: %w", err)
	}
	output, readErr := io.ReadAll(resp.Reader)
	resp.Close()
	if readErr != nil {
		return nil, fmt.Errorf("failed to read file-check output: %w", readErr)
	}
	inspect, err := fte.docker.ContainerExecInspect(ctx, createResp.ID)
	if err != nil {
		return nil, fmt.Errorf("failed to inspect file-check exec: %w", err)
	}
	if inspect.ExitCode != 0 {
		return nil, fmt.Errorf("file-check exec failed with exit code %d: %s", inspect.ExitCode, strings.TrimSpace(string(output)))
	}

	byContainerPath := make(map[string]fileSyncEntry, len(entries))
	for _, e := range entries {
		byContainerPath[e.containerPath] = e
	}

	var missing []fileSyncEntry
	for _, line := range strings.Split(string(output), "\n") {
		line = strings.TrimSpace(line)
		if line == "" {
			continue
		}
		if e, ok := byContainerPath[line]; ok {
			missing = append(missing, e)

View on GitHub (pinned to ea665308ba)

Solutions

  1. Verify the daemon has not restarted: docker info, check dockerd uptime vs error timestamp
  2. Ensure nothing removes the sandbox container while the flow runs (check cleanup goroutines and container timeouts)
  3. Confirm the exec ID is valid by re-running the flow and checking ContainerExecCreate succeeded just before inspect
  4. Inspect the wrapped error for 'No such exec'/'No such container' and treat it as container teardown rather than a tools bug

Example fix

// before
inspect, err := fte.docker.ContainerExecInspect(ctx, createResp.ID)
if err != nil {
	return nil, fmt.Errorf("failed to inspect file-check exec: %w", err)
}
// after
inspect, err := fte.docker.ContainerExecInspect(ctx, createResp.ID)
if err != nil {
	if ctx.Err() != nil {
		return nil, fmt.Errorf("file-check canceled: %w", ctx.Err())
	}
	return nil, fmt.Errorf("failed to inspect file-check exec: %w", err)
}
Defensive patterns

Strategy: validation

Validate before calling

// verify daemon reachability and container presence before the exec lifecycle
cli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
if err != nil {
	return err
}
if _, err := cli.ContainerInspect(ctx, containerID); err != nil {
	return fmt.Errorf("container %s unavailable: %w", containerID, err)
}

Try / catch

err := runFileCheck(ctx)
if err != nil {
	var notFound bool
	if strings.Contains(err.Error(), "No such exec") || strings.Contains(err.Error(), "No such container") {
		notFound = true
	}
	if notFound {
		// container/daemon state lost: recreate sandbox and re-run, not a code bug
		return recreateSandboxAndRetry(ctx)
	}
	return err
}

Prevention

When it happens

Trigger: fte.docker.ContainerExecInspect(ctx, createResp.ID) returns an error: the exec instance no longer exists (daemon restarted or removed the record), the container was removed, daemon unreachable, or ctx canceled.

Common situations: Docker daemon restarted between exec creation and inspect, pruning exec records; sandbox container removed by a concurrent cleanup/timeout routine; DOCKER_HOST connection issues in multi-host deployments.

Related errors


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