fix: preserve stdin taskfile bytes - #2950
Open
cuishuang wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
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.Scannerusage withio.ReadAll(os.Stdin)inStdinNode.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" | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
StdinNode.Readusedbufio.Scannerto read a Taskfile line by line.Scannerhas a default maximum token size of 64 KiB, so a Taskfile containing a longer line failed with:The previous implementation also removed the original line endings and added
\nafter 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.ReadAlland preserve the input bytes.