Skip to content

[Rust] Rerun the SDK build script on proto change - #1049

Merged
dimitrije-djordjevic-db merged 3 commits into
mainfrom
proto-rerun-fix
Nov 24, 2026
Merged

dimitrije-djordjevic-db merged 3 commits into
mainfrom
proto-rerun-fix

Conversation

@dimitrije-djordjevic-db

@dimitrije-djordjevic-db dimitrije-djordjevic-db commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

What changes are proposed in this pull request?

What: rust/sdk/build.rs now prints cargo:rerun-if-changed=zerobus_service.proto and cargo:rerun-if-changed=build.rs before it compiles the protos. rust/test-support/build.rs, which compiles the same proto for the mock server, now lists it too.

Why: in builds with the zeroparser feature, a change to zerobus_service.proto was silently ignored. Cargo kept the old generated gRPC code, so new messages or RPCs looked missing until a clean build.

How it happens:

  • Cargo reruns a build script on any file change in the package only while the script prints no rerun-if-changed lines. Once it prints any, Cargo reruns the script only when one of the listed paths changes (Cargo docs).
  • prost-build 0.14 prints no rerun-if-changed for the protos it compiles, on purpose (see the TODO in prost-build/src/config.rs, compile_protos). tonic-prost-build 0.14.5 has an emit_rerun_if_changed setting, but never uses it. Without zeroparser, the SDK build script therefore relies on Cargo's any-change default, which works.
  • With zeroparser, src/zeroparser/proto_build.rs prints rerun-if-changed for its two test and bench proto directories. That turns off the default, and zerobus_service.proto is not on the list.
  • zeroparser is enabled in more builds than it seems: the tests crate depends on the SDK with zeroparser, so feature unification turns it on for cargo test --workspace, cargo clippy --workspace (both run by make test / make lint) and any --all-features build.

Who it affects: anyone who edits zerobus_service.proto locally, or switches between branches with different protos, and then builds the workspace. We hit it while adding the InsertRecords RPC (#1025): after a branch switch, cargo clippy --workspace reported no InsertRecordsRequest in proto::databricks::zerobus even though the proto had it. CI is not affected, because it always builds from a clean target directory.

The test-support build script had the same problem without any feature: the proto lives outside its package, so Cargo's any-change default never saw a proto change.

Listing build.rs keeps the script rerunning when the script itself changes. No other file feeds the build script: zeroparser/proto_build.rs is compiled into it, so a change there rebuilds and reruns it anyway.

How is this tested?

A probe that adds message RerunProbe {} to the proto, rebuilds, and checks the generated databricks.zerobus.rs in the build script's out_dir (taken from Cargo's build-script-executed JSON message):

Build Before After
default features regenerated regenerated
--features zeroparser stale, change ignored regenerated
--all-features not measured (also enables zeroparser) regenerated

Also: cargo fmt --check, and cargo clippy -p databricks-zerobus-ingest-sdk --all-targets --all-features -- -D warnings.

This pull request and its description were written by Isaac.

prost-build emits no cargo:rerun-if-changed for the protos it compiles,
so the build script relied on Cargo's default of rerunning on any
package change. That default stops applying as soon as a script emits
any rerun-if-changed, and the zeroparser build emits two. In builds
with the zeroparser feature, a change to zerobus_service.proto was
therefore ignored and the old generated code kept until a clean build.

List zerobus_service.proto and build.rs explicitly.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Dimitrije Đorđević <dimitrije.djordjevic@databricks.com>
The test-support build script compiles the SDK's service proto, which
lives outside its package, and emits no rerun-if-changed. Cargo then
reruns it only when a file inside test-support changes, so a proto
change left the mock server on the old schema until a clean build.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Dimitrije Đorđević <dimitrije.djordjevic@databricks.com>

@teodordelibasic-db teodordelibasic-db left a comment

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.

LGTM

@dimitrije-djordjevic-db
dimitrije-djordjevic-db added this pull request to the merge queue Nov 23, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Nov 23, 2026
Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Dimitrije Đorđević <dimitrije.djordjevic@databricks.com>
@dimitrije-djordjevic-db
dimitrije-djordjevic-db added this pull request to the merge queue Nov 24, 2026
Merged via the queue into main with commit cc7f727 Nov 24, 2026
52 checks passed
@dimitrije-djordjevic-db
dimitrije-djordjevic-db deleted the proto-rerun-fix branch November 24, 2026 15:01
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.

2 participants