Skip to content

fix(bazel): parse Bazel 9 JSON build events - #1359

Merged
trunk-io[bot] merged 1 commit into
mainfrom
tylerbeebe/bazel-9-bep-protos
Nov 18, 2026
Merged

trunk-io[bot] merged 1 commit into
mainfrom
tylerbeebe/bazel-9-bep-protos

Conversation

@acatxnamedvirtue

Copy link
Copy Markdown
Contributor

Problem

--bazel-bep-path with a JSON build event file from Bazel 9 finds no tests. The flake farm's bazel_test (local, json) job on Bazel 9.0.1 shows it, on 0.17.0 and 1.0.0-beta.1 alike:

⚠️  BEP file had a parse error: Error parsing build event: unknown variant `NON_CONFIGURABLE`, expected one of `EXPERIMENTAL`, `INCOMPATIBLE_CHANGE`, `DEPRECATED`, `HIDDEN`, `INTERNAL`
   Total: 0   Pass: 0   Fail: 0   Quarantined: 0   Pass Ratio: N/A
⚠️  No tests were found in the provided test results, but non zero exit code provided: 1
  • JSON fails: Bazel 9 adds NON_CONFIGURABLE to OptionMetadataTag, and the JSON parser that pbjson generates rejects an enum name it doesn't know.
  • Binary is fine: the binary parser (prost) keeps unknown enum numbers, so the farm's bazel_test (local, binary) job uploads normally.

Change

  • Protos: updates the vendored protos in bazel-bep/proto/ to Bazel 9.0.1, with imports flattened as before.
  • New file: adds strategy_policy.proto, which invocation_policy.proto now imports, with its module in bazel-bep/src/lib.rs.
  • README: records the Bazel version, and corrects its list of upstream proto paths (most live under src/main/protobuf/).

No enum value was removed:

  • action_cache.proto's MissReason values only gain "currently not used" comments.
  • The event types Bazel 9 dropped from build_event_stream.proto (WorkflowConfigured, ChildInvocation*, RunTargetAnalyzed, CoverageActionsFinished, Tree) are field names in JSON, which ignore_unknown_fields already skips. Nothing in the CLI or context uses them.

Follow-up

pbjson-build 0.9 has ignore_unknown_enum_variants, which would stop the next new Bazel enum value from breaking JSON parsing. It means moving prost and tonic up several versions, so it's left for after 1.0.0.

Testing

  • New test_parse_bazel_9_json_bep, with a bep_bazel_9.json fixture carrying "metadataTags": ["NON_CONFIGURABLE"]. It fails with the old protos and passes with these.
  • The context and bazel-bep suites pass, and so do the CLI's BEP and Bazel tests.
  • cargo check --workspace --all-targets passes, and trunk check is clean.

🤖 Generated with Claude Code

Bazel 9 tags options NON_CONFIGURABLE, a value our Bazel 8-era
option_filters.proto lacks. The pbjson JSON parser rejects an unknown
enum name, so --bazel-bep-path with Bazel 9 JSON found no tests at all.
The binary parser was unaffected, since prost keeps unknown enum numbers.

Update the vendored protos to Bazel 9.0.1, adding strategy_policy.proto,
which invocation_policy.proto now imports.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@trunk-io

trunk-io Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

😎 Stack merged successfully - details.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.82%. Comparing base (26ec370) to head (e654981).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1359      +/-   ##
==========================================
+ Coverage   85.61%   85.82%   +0.21%     
==========================================
  Files          85       85              
  Lines       19174    19186      +12     
==========================================
+ Hits        16416    16467      +51     
+ Misses       2758     2719      -39     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

DIFFERENT_DEPS = 1;
DIFFERENT_ENVIRONMENT = 2;
DIFFERENT_FILES = 3;
DIFFERENT_ACTION_KEY = 0; // currently not used

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

we should copy these verbatim from source imo, without the annotations here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

These are verbatim. The // currently not used comments are Bazel's: src/main/protobuf/action_cache.proto at 9.0.1, lines 36–39. Our copy matches it byte for byte.

I diffed all eight files against Bazel 9.0.1. The only lines that differ are the import paths: import "src/main/protobuf/option_filters.proto" becomes import "option_filters.proto", because every file sits directly in bazel-bep/proto/ and build.rs compiles with proto/ as the only include root. The README's update steps now say so.

const FLAKY_SUMMARY_EXAMPLE: &str = "test_fixtures/bep_flaky_summary";
const RETRIES_EXAMPLE: &str = "test_fixtures/bep_retries";
const UNKNOWN_FIELDS_EXAMPLE: &str = "test_fixtures/bep_unknown_fields.json";
const BAZEL_9_EXAMPLE: &str = "test_fixtures/bep_bazel_9.json";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

yay for historical fixtures so we know we didn't break anything

@trunk-io
trunk-io Bot merged commit 05937c7 into main Nov 18, 2026
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants