Skip to content

tools: keep protobuf generation reproducible and generated files in sync #1527

Closed

Description

@aholden85

Describe the feature you'd like and the problem it will solve

Running ./tools/gen_pb_go.sh from a clean checkout of main modifies 25 generated .pb.go files. When regenerating Starlark protobufs, 24 of those changes are unrelated files and appear to be comment-indentation changes, creating noisy diffs for feature PRs.

I verified the output is deterministic across repeated runs. The committed and regenerated file headers also report the same versions (protoc-gen-go v1.36.12 and protoc v6.33.5), so the version difference between the generator and go.mod's protobuf runtime dependency (v1.36.11) does not explain this indentation drift.

For example, probes/ping/proto/config.proto contains this comment:

  //     sudo sysctl -w net.ipv4.ping_group_range="0 <large valid group id>"

The committed probes/ping/proto/config.pb.go renders it with a tab after //, while a fresh generation preserves the spaces from the .proto source. This suggests some checked-in generated files are stale relative to their source comments.

The generation script also installs protoc-gen-go and protoc-gen-go-grpc using @latest, so the plugin versions can change over time without a repository change.

Please consider:

  • Bringing checked-in generated protobuf files into sync with their current .proto sources, so a clean regeneration does not produce unrelated comment-only diffs.
  • Pinning the protobuf compiler and Go generator plugin versions used by tools/gen_pb_go.sh so future output is reproducible.

Note

This was discovered while working on #1513.

Activity

  1. added
    enhancement
    on Oct 5, 2026
  2. manugarg commented on Oct 5, 2026

    @manugarg
    Contributor

    Thanks for the detailed report. I could reproduce the diff, but the cause is different from what the issue suggests: the checked-in files aren't stale.

    With protoc 33.5 and protoc-gen-go v1.36.12, the output depends on the Go version used to build the plugin:

    Go version building protoc-gen-go .pb.go files changed on main
    1.23, 1.24, 1.25, 1.26.6 0
    1.27.0 26

    The 1.27 diff is comment-only and matches what you describe, including the ping_group_range example. I'm guessing you're on Go 1.27. go install ...@latest builds the plugin with the locally installed Go rather than the version in go.mod (currently 1.26.6), so that was the unpinned variable. The plugin versions themselves happened to match.

    #1528 fixes this in tools/gen_pb_go.sh by:

    • pinning protoc-gen-go and protoc-gen-go-grpc versions, as you suggested, and
    • building the plugins with the Go version from go.mod (via GOTOOLCHAIN), so the output is the same regardless of the local Go install.

    We'll regenerate everything in one commit when go.mod moves to Go 1.27, rather than now, as doing it now would move the noise to everyone on 1.26.

    For #1513: please drop the unrelated .pb.go changes. Once #1528 is in, rebasing and re-running the script should touch only the starlark proto.

  3. aholden85 commented on Oct 5, 2026

    @aholden85
    ContributorAuthor

    Thanks Manu - you're completely right, I'm on go version go1.27.1 darwin/arm64.

    I've only included the relevant changes in #1513 rather than the changes made to ALL .pb.go files - take a look and lemme know if that's ok, or if you also want me to make changes to probes/starlark/proto/config.proto.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions