Skip to content

Fix script output dropping last line without trailing newline#4995

Open
denik wants to merge 4 commits intomainfrom
denik/random-bugfixes-4
Open

Fix script output dropping last line without trailing newline#4995
denik wants to merge 4 commits intomainfrom
denik/random-bugfixes-4

Conversation

@denik
Copy link
Copy Markdown
Contributor

@denik denik commented Apr 16, 2026

Changes

Fix experimental.scripts hooks silently dropping the last line of output when it doesn't end with a trailing newline (e.g. printf "done").

Tests

Added acceptance test at acceptance/bundle/scripts/no-trailing-newline/ and unit tests for the script executor.

Running the acceptance test against the previous release demonstrates the bug:

$ go test ./acceptance -run 'TestAccept/bundle/scripts/no-trailing-newline' -useversion 0.296.0

--- Expected
+++ Actual (v0.296.0)
@@ -5,3 +5,2 @@
 line 2
-line without newline
 Name: scripts_no_trailing_newline

v0.296.0 drops "line without newline" because the last line has no trailing \n. The fix correctly includes it.

denik added 4 commits April 16, 2026 14:14
bufio.Reader.ReadString returns both data and io.EOF when the stream
ends without a delimiter. The old loop condition `for err == nil` caused
the last line of output to be silently dropped when it lacked a trailing
newline. This affected any bundle script (experimental.scripts hooks)
whose output didn't end with `\n`.

Restructure the loop to always process data before checking for errors,
which is the idiomatic Go pattern for ReadString.

Task: 001.md

Co-authored-by: Isaac
Co-authored-by: Isaac
This test demonstrates the bug where the last line of script output
was dropped when it didn't end with a trailing newline. Running this
test with -useversion 0.296.0 shows the bug: "line without newline"
is missing from the output.

Task: 002.md

Co-authored-by: Isaac
@github-actions
Copy link
Copy Markdown

Approval status: pending

/acceptance/bundle/ - needs approval

Files: acceptance/bundle/scripts/no-trailing-newline/databricks.yml, acceptance/bundle/scripts/no-trailing-newline/myscript.py, acceptance/bundle/scripts/no-trailing-newline/out.test.toml, acceptance/bundle/scripts/no-trailing-newline/output.txt, acceptance/bundle/scripts/no-trailing-newline/script
Suggested: @andrewnester
Also eligible: @pietern, @lennartkats-db, @shreyas-goenka, @anton-107, @janniklasrose

/bundle/ - needs approval

Files: bundle/scripts/scripts.go, bundle/scripts/scripts_test.go
Suggested: @andrewnester
Also eligible: @pietern, @lennartkats-db, @shreyas-goenka, @anton-107, @janniklasrose

General files (require maintainer)

Files: NEXT_CHANGELOG.md
Based on git history:

  • @andrewnester -- recent work in ./

Any maintainer (@andrewnester, @anton-107, @pietern, @shreyas-goenka, @simonfaltum, @renaudhartert-db) can approve all areas.
See OWNERS for ownership rules.

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.

1 participant