[PR #57] [MERGED] Use docker’s stdcopy to ensure we don’t emit garbage bytes to stdout #1342

Closed
opened 2026-03-01 21:50:46 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/nektos/act/pull/57
Author: @aidansteele
Created: 4/9/2019
Status: Merged
Merged: 5/23/2019
Merged by: @cplee

Base: masterHead: fix-nontty


📝 Commits (1)

  • 1d64fef Use docker’s stdcopy to ensure we don’t emit garbage bytes to stdout

📊 Changes

2 files changed (+60 additions, -6 deletions)

View changed files

📝 container/docker_common.go (+5 -6)
container/docker_run_test.go (+55 -0)

📄 Description

As per the ContainerAttach() docs, a container not using a TTY has stderr and stdout multiplexed into a single stream in a Docker-specific format.

When running act and its stdout is not a terminal (e.g. when it's redirected to a file), DockerExecutorInput.logDockerOutput() is invoked -- I've changed this to use github.com/docker/docker/pkg/stdcopy.StdCopy as per Docker's suggestion.

Right now the issue is the tests pass when output is redirected to a file and fail when run directly in a terminal! ️ This is because of the following two conflicting pieces:

github.com/nektos/act@f2cb9e391e/container/docker_run.go (L89-L97)

github.com/nektos/act@f2cb9e391e/container/docker_run.go (L170-L171)

Honestly, I'm not sure what the purpose of the NORAW env var is. If NORAW is passed in, the tests will fail in even more spectacular ways. I would like to do the following, but wanted to run it by you first before submitting this PR:

  • Instead of terminal.IsTerminal() in attachContainer(), we use the Docker API client to introspect the container and see if it is in TTY mode or not.
  • Additionally, add Tty *bool to NewDockerRunExecutorInput and only fall back to terminal.IsTerminal() if it is nil.

What are your thoughts?


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/nektos/act/pull/57 **Author:** [@aidansteele](https://github.com/aidansteele) **Created:** 4/9/2019 **Status:** ✅ Merged **Merged:** 5/23/2019 **Merged by:** [@cplee](https://github.com/cplee) **Base:** `master` ← **Head:** `fix-nontty` --- ### 📝 Commits (1) - [`1d64fef`](https://github.com/nektos/act/commit/1d64fef1a13a810550b3bba08bfaa23c7c63522b) Use docker’s stdcopy to ensure we don’t emit garbage bytes to stdout ### 📊 Changes **2 files changed** (+60 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `container/docker_common.go` (+5 -6) ➕ `container/docker_run_test.go` (+55 -0) </details> ### 📄 Description As per the [`ContainerAttach()` docs](https://github.com/docker/go-docker/blob/4daae26030ad00e348edddff9767924ae57a3b82/container_attach.go#L17-L33), a container _not_ using a TTY has stderr and stdout multiplexed into a single stream in a Docker-specific format. When running `act` and its stdout is not a terminal (e.g. when it's redirected to a file), `DockerExecutorInput.logDockerOutput()` is invoked -- I've changed this to use `github.com/docker/docker/pkg/stdcopy.StdCopy` as per Docker's suggestion. Right now the issue is the tests pass when output is redirected to a file and fail when run directly in a terminal! ❗️ This is because of the following two conflicting pieces: https://github.com/nektos/act/blob/f2cb9e391e504b7b507bb75415da040d558e46ba/container/docker_run.go#L89-L97 https://github.com/nektos/act/blob/f2cb9e391e504b7b507bb75415da040d558e46ba/container/docker_run.go#L170-L171 Honestly, I'm not sure what the purpose of the `NORAW` env var is. If `NORAW` is passed in, the tests will fail in even more spectacular ways. I would _like_ to do the following, but wanted to run it by you first before submitting this PR: * Instead of `terminal.IsTerminal()` in `attachContainer()`, we use the Docker API client to introspect the container and see if it is in TTY mode or not. * Additionally, add `Tty *bool` to `NewDockerRunExecutorInput` and only fall back to `terminal.IsTerminal()` if it is nil. What are your thoughts? --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-01 21:50:46 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/act#1342
No description provided.