Skip to content

fix(bes): write the caller's --build_event_binary_file - #1389

Draft
mcook42 wants to merge 4 commits into
mainfrom
fix/bep-file-not-written
Draft

fix(bes): write the caller's --build_event_binary_file#1389
mcook42 wants to merge 4 commits into
mainfrom
fix/bep-file-not-written

Conversation

@mcook42

@mcook42 mcook42 commented Aug 13, 2026

Copy link
Copy Markdown
Member

Split out of #1370 (fix 2 of 3). See that PR's description for full context on all three defects found in the same investigation.

A caller's --build_event_binary_file was silently never written. Build::spawn appends the CLI's own --build_event_binary_file after every user flag; Bazel's option is single-valued, so last-wins meant a caller who asked for a BEP file got a path that was created but never written to. The IntelliJ Bazel plugin parses sync results from that file, so even with the --target_pattern_file conflict fixed separately, it would have read an empty file.

Fixed by collecting a file sink for the caller's path in collect_bes_sinks, rather than stripping or reordering flags. The CLI's path still wins on the command line; the caller's file is recreated from Bazel's own byte stream, since file sinks share the BES reader's raw-bytes path.

Test plan

  • New test cases — bazel_bep_file resolution and the collect_bes_sinks file-sink append in build_events_test.axl. Verified locally: bazel run //crates/aspect-cli:aspect-cli -- dev test-bes-sinksbuild_events_test.axl: OK (14 tests).
  • New CI coverage — extends test-flags-task in both .buildkite/pipeline.yaml and .github/workflows/ci-workflows.yaml with one aspect build in the plugin's exact shape (--bazel-flag=--build_event_binary_file=...), asserting a non-empty BEP at the caller's path.

Before / after (captured on main)

Check Before After
Caller's BEP file never created non-empty, contains the target label
WARNING: BES was not properly closed present gone

@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0b32ef41-5931-4243-922a-baabc5f2e390

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@aspect-workflows

aspect-workflows Bot commented Aug 13, 2026

Copy link
Copy Markdown

✨ Aspect Workflows Tasks

📅 Fri Aug 14 15:03:49 UTC 2026

✅ 2 successful tasks

  • ✅ build-gha [build] · ⏱ 8m 11s · ✨ Aspect · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel build complete (172 built)
  • ✅ test-gha [test] · ⏱ 4m 10s · ✨ Aspect · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (26/26 passed · 26 cached)

⏱ Last updated Fri Aug 14 15:11:51 UTC 2026 · 📊 GitHub API quota 9/15,000 (0% used, resets in 58m)
🚀 Powered by Aspect CLI (v0.0.0-dev)  |  Aspect Build · X · LinkedIn · YouTube

@mcook42
mcook42 force-pushed the fix/bep-file-not-written branch from 7fd7cde to d799a68 Compare August 13, 2026 15:57
`Build::spawn` appends the CLI's own `--build_event_binary_file` after
every user flag. Bazel's option is single-valued, so last-wins meant a
caller who asked for a BEP file silently got nothing — the file was
created by whoever made the temp path and never written to.

The IntelliJ Bazel plugin drives sync on exactly that flag, so even with
the target-pattern collision fixed it would parse an empty file.

Collect a file sink for the caller's path instead of stripping or
reordering flags. The CLI's path still wins on the command line; the
caller's file is re-created from Bazel's own byte stream, since file
sinks share the BES reader's raw-bytes path. Placed in
`collect_bes_sinks` so all eight bazel-spawning tasks are covered — every
one of them hit the same clobbering.

Two consequences: `--build_event_binary_file_upload_mode` no longer
governs that file (the caller's existing `sink.wait()` completes it,
before the task concludes), and `--build_event_json_file` /
`--build_event_text_file` are untouched — different flags, so Bazel still
writes those itself.
The unit tests cover collect_bes_sinks in isolation, but nothing
exercised it end to end: that a caller's --build_event_binary_file,
forwarded in the shape the IntelliJ Bazel plugin produces (Bazel's own
flag spelling behind --bazel-flag), actually lands on disk.

Extend the existing test-flags-task step in both pipelines with one
aspect build in that shape, asserting a non-empty BEP at the caller's
path.

Split out of the combined IDE/BSP smoke-test commit in #1370 — the
--target_pattern_file half goes with that fix's own PR.
@mcook42
mcook42 force-pushed the fix/bep-file-not-written branch from d799a68 to 81b53d8 Compare August 13, 2026 22:26
Two prior commits (81b53d8, dd4a1dc) each independently extended
the test-flags-task comment block with their own IDE/BSP explanation.
The merge (87e5694) interleaved both without deduplicating their
shared boilerplate, leaving a garbled, self-contradicting comment.
Merge the two explanations into one coherent paragraph; no script
changes.
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