Skip to content

Conversation

SarahFrench
Copy link
Member

Context from hashicorp/terraform-plugin-go:

It looks like there are some bugs in this script, found by @austinvalle when he debugged some issues after I copied a version of the script into that repo.

This PRs changes are:

  • Correct an error that meant protoc-gen-go-grpc wasn't actually being used as a plugin
  • Changes to the arguments passed to the exec.Cmd that generates the code (for each job defined in protocSteps):
    • The docs for exec.Cmd say "Args holds command line arguments, including the command as Args[0]."

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.

The docs say "Args holds command line arguments, including the command as Args[0]."
@SarahFrench
Copy link
Member Author

Note - I've removed protoc, protoc-gen-go and protoc-gen-go-grpc from my PATH and running make protobuf succeeds,. i.e. no diffs occur unless I make a change to a .proto file

@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 marked this pull request as ready for review September 26, 2025 10:58
@SarahFrench SarahFrench requested a review from a team as a code owner September 26, 2025 10:58
@SarahFrench SarahFrench marked this pull request as draft September 26, 2025 11:00
Comment on lines +36 to 38
//
// TODO: Swap to using google.golang.org/protobuf/cmd/protoc-gen-go
const protocGenGoPackage = "github.com/golang/protobuf/protoc-gen-go"
Copy link
Member Author

Choose a reason for hiding this comment

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

I investigated this change but it requires significant changes to the flags passed into protoc, so I think it's worth addressing in a separate PR.

@SarahFrench SarahFrench marked this pull request as ready for review September 26, 2025 11:41
Comment on lines 149 to 162
protocGenGoGrpcExec, err := buildProtocGenGoGrpc(workDir)
if err != nil {
log.Fatal(err)
}

protocExec, err = filepath.Abs(protocExec)
if err != nil {
log.Fatal(err)
}
protocGenGoExec, err = filepath.Abs(protocGenGoExec)
if err != nil {
log.Fatal(err)
}
protocGenGoGrpcExec, err := filepath.Abs(protocGenGoExec)
protocGenGoGrpcExec, err = filepath.Abs(protocGenGoGrpcExec)
Copy link
Member Author

@SarahFrench SarahFrench Sep 26, 2025

Choose a reason for hiding this comment

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

Just to add a few more details to these changes:

Prior to these changes both --plugin flags were passing in protoc-gen-go, and meanwhile protoc-gen-go-grpc was unused.

Now, protoc-gen-go-grpc is being supplied to protoc as a plugin.

However, we're using an old version of protoc-gen-go that includes the ability to generate grpc; I don't think protoc-gen-go-grpc is used regardless.

Copy link
Member Author

Choose a reason for hiding this comment

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

If I change this line:

baseCmdLine := []string{protocExec, "--plugin=" + protocGenGoExec, "--plugin=" + protocGenGoGrpcExec}

to remove the second --plugin flag then the output is the same as when protoc-gen-go-grpc is provided. So I don't believe there's any issue with supplying this plugin despite it not being used.

@SarahFrench SarahFrench merged commit c0547e7 into main Sep 26, 2025
13 checks passed
@SarahFrench SarahFrench deleted the sarah/fixes-to-protobuf-compile branch September 26, 2025 17:08
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