Skip to content

fix: preserve stdin taskfile bytes - #2950

Open
cuishuang wants to merge 1 commit into
go-task:mainfrom
cuishuang:fix-stdin-taskfile-read
Open

fix: preserve stdin taskfile bytes#2950
cuishuang wants to merge 1 commit into
go-task:mainfrom
cuishuang:fix-stdin-taskfile-read

Conversation

@cuishuang

Copy link
Copy Markdown

StdinNode.Read used bufio.Scanner to read a Taskfile line by line.

Scanner has a default maximum token size of 64 KiB, so a Taskfile containing a longer line failed with:

bufio.Scanner: token too long

The previous implementation also removed the original line endings and added \n after every scanned line. This converted CRLF input to LF and added a trailing newline when the input did not contain one.

This differed from regular Taskfile reads, which use io.ReadAll and preserve the input bytes.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates StdinNode.Read to preserve raw Taskfile bytes read from stdin by switching from line-based bufio.Scanner parsing to io.ReadAll, avoiding the 64 KiB scanner token limit and preserving original line endings and trailing newline behavior.

Changes:

  • Replace bufio.Scanner usage with io.ReadAll(os.Stdin) in StdinNode.Read.
  • Add tests ensuring stdin reads preserve bytes for long lines, CRLF endings, missing trailing newline, and empty input.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
taskfile/node_stdin.go Switch stdin Taskfile reading to io.ReadAll to preserve bytes and avoid scanner limits.
taskfile/node_stdin_test.go Add coverage for byte-preserving stdin reads across edge cases.
Suppressed comments (1)

taskfile/node_stdin_test.go:53

  • Use filepath.Join here to build the temp file path in an OS-agnostic way (avoids hardcoding "/").
	path := t.TempDir() + "/stdin"

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +3 to +10
import (
"os"
"strings"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants