Skip to content

fix(cli): Propagate bundle render output errors - #618

Merged
stefanprodan merged 1 commit into
stefanprodan:mainfrom
reneleonhardt:fix/bundle-render-output
Aug 10, 2026
Merged

fix(cli): Propagate bundle render output errors#618
stefanprodan merged 1 commit into
stefanprodan:mainfrom
reneleonhardt:fix/bundle-render-output

Conversation

@reneleonhardt

Copy link
Copy Markdown
Contributor

What

Make a successful timoni bundle build exit guarantee that the complete in-memory render was accepted by stdout. Propagate the final writer error, and report io.ErrShortWrite when the writer accepts fewer bytes without returning an error. The command, flags, rendered bytes, ordering, concurrency, and existing --output-dir behavior stay unchanged; the --output-dir path already returned file write errors and is untouched.

Why

Bundle rendering already has an excellent automation shape: Timoni builds every instance in memory, preserves bundle order, and performs one final stdout write only after the whole render succeeds. The final Write result is currently discarded, so a full, closed, or otherwise failing output sink can receive incomplete data while Timoni reports success. This fix turns the exit status into a dependable completeness signal for artifact pipelines and other render-only consumers, without adding a destination directory, staging tree, or apply step.

Reproduction

The command before and after this change is identical.

# Linux: a failing output sink (writes fail with ENOSPC).
timoni bundle build -f bundle.cue >/dev/full
echo $?

# main: discards the write error, leaves the stdout stream empty, still exits 0.
# this PR: returns the write error, logs it to stderr, exits 1.

What the reviewer must decide

  1. Whether failing the command on a short write with a nil error (not only on a returned writer error) is the right completeness contract for a render-only stdout command.
  2. Whether keeping the sibling single-instance timoni build on its existing behavior (it already propagates the write error but does not check short writes) is acceptable, or whether the two render commands should share the same check.

Verification

go test ./cmd/timoni/ -run 'Test_BundleBuild' -count=1

The focused suite covers a sentinel writer failure, a nil-error short write, an ordinary render failure with zero output, existing stdout bytes and ordering, and unchanged directory output.

Developed with carefully directed, manually reviewed AI assistance.

Co-Authored-By: GPT-5.6 Sol codex@openai.com

Bundle build assembles the full render in memory and writes stdout in one
pass only after every instance succeeds, but the final Write result was
discarded, so a failing or short writer could receive incomplete output
while the command reported success. Propagate the writer error and report
io.ErrShortWrite when a nil-error writer accepts fewer bytes. The
--output-dir path is unchanged.

Signed-off-by: Rene Leonhardt <65483435+reneleonhardt@users.noreply.github.com>
Co-Authored-By: GPT-5.6 Sol <codex@openai.com>
@stefanprodan stefanprodan added the area/cli CLI related issues and pull requests label Aug 10, 2026

@stefanprodan stefanprodan left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

LGTM

Thanks @reneleonhardt

@stefanprodan
stefanprodan merged commit 4f9a732 into stefanprodan:main Aug 10, 2026
5 checks passed
@reneleonhardt
reneleonhardt deleted the fix/bundle-render-output branch August 10, 2026 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/cli CLI related issues and pull requests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants