Skip to content

Conversation

@SarahFrench
Copy link
Member

@SarahFrench SarahFrench commented Sep 26, 2025

This PR migrates hashicorp/terraform away from the github.com/golang/protobuf/protoc-gen-go module to google.golang.org/protobuf/cmd/protoc-gen-go. The difference is explained nicely in golang/protobuf#1070 (comment):

The google.golang.org/protobuf/cmd/protoc-gen-go program doesn't include gRPC support. Instead, that support will soon be provided by a google.golang.org/grpc/cmd/protoc-gen-go-grpc program. That program is In code review now, but not quite yet available.

The github.com/golang/protobuf/protoc-gen-go program supports gRPC as always, and will continue to do so. Versions v1.4 and newer of that program support the new protobuf reflection features. (Right now, the newest release is v1.4.0-rc.4.)

So, we're currently using the old, deprecated version of protoc-gen-go which generates both Go code and Go code for gRPC. We're swapping to a newer version of protoc-gen-go that only generates Go code, and we'll start relying on protoc-gen-go-grpc to generate gRPC-related Go code.

What this change looks like is:

  • Whereas a single .pg.go file was generated before, now separate .pg.go and _grpc.pb.go files are generated.
  • Flags passed to protoc need to be updated; protoc-gen-go no longer accepts a grpc plugin and instead flags need to be passed to protoc-gen-go-grpc.

Also, we need to navigate an issue linked to future-proofing services: https://pkg.go.dev/google.golang.org/grpc/cmd/protoc-gen-go-grpc#readme-future-proofing-services

In 89fccc4 I've chosen to disable that feature, which results in generated code that resembles the previous version. We should have conversations about enabling that feature in future.

Target Release

N/A

Rollback Plan

  • If a change needs to be reverted, we will roll out an update to the code within 7 days.

Changes to Security Controls

Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.

CHANGELOG entry

  • This change is user-facing and I added a changelog entry.
  • This change is not user-facing.

@SarahFrench SarahFrench added the no-changelog-needed Add this to your PR if the change does not require a changelog entry label Sep 26, 2025
@SarahFrench SarahFrench changed the base branch from main to sarah/fixes-to-protobuf-compile September 26, 2025 13:35
Base automatically changed from sarah/fixes-to-protobuf-compile to main September 26, 2025 17:08
…rpc support (instead it relies on protoc-gen-go-grpc).

Update command flags to reflect this change in tooling.

See this comment for explanation: golang/protobuf#1070 (comment)
…time of upgrading tooling

In future we can navigate the consequences of this in its own PR.
@SarahFrench SarahFrench force-pushed the sarah/use-undeprecated-protoc-gen-go branch from 951eb9c to 6b3cbf5 Compare September 26, 2025 18:03
…mod tidy`

This version includes a feature that allows the copyright comment in the .proto file to be pulled across to generated _grpc.pb.go files.
…s copyright comment to be copied to generated output files
@SarahFrench
Copy link
Member Author

SarahFrench commented Sep 29, 2025

Now there's an issue in this PR's checks with this script hitting this default case:

log.Fatalf("don't know how to make a stub for method with %d results", n)

Looking into it now.

@SarahFrench SarahFrench marked this pull request as ready for review September 29, 2025 10:09
@SarahFrench SarahFrench requested review from a team and tommyokeefe as code owners September 29, 2025 10:09
// > Docs: https://pkg.go.dev/google.golang.org/grpc/cmd/protoc-gen-go-grpc#readme-future-proofing-services
// > PR for Unsafe interfaces: https://github.com/grpc/grpc-go/pull/3911
continue Types
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This change is related to this issue I highlighted in an earlier comment. This script is written expecting .pb.go files generated from the old github.com/golang/protobuf/protoc-gen-go tooling. With the new tooling in this PR there are some new interfaces that this script needs to be updated to tolerate.

I took inspiration from L83-L85, but I need review from someone more familiar with the purpose of this script (paging @liamcervante).

Copy link
Member

Choose a reason for hiding this comment

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

This makes sense to me, and given it produces no changes in the relevant generated code that seems safe 👍

Copy link
Member

@liamcervante liamcervante left a comment

Choose a reason for hiding this comment

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

Looks good!

// > Docs: https://pkg.go.dev/google.golang.org/grpc/cmd/protoc-gen-go-grpc#readme-future-proofing-services
// > PR for Unsafe interfaces: https://github.com/grpc/grpc-go/pull/3911
continue Types
}
Copy link
Member

Choose a reason for hiding this comment

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

This makes sense to me, and given it produces no changes in the relevant generated code that seems safe 👍

@SarahFrench SarahFrench merged commit ffbb62b into main Sep 30, 2025
13 checks passed
@SarahFrench SarahFrench deleted the sarah/use-undeprecated-protoc-gen-go branch September 30, 2025 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog-needed Add this to your PR if the change does not require a changelog entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants