Skip to content

Conversation

@jskeet
Copy link
Contributor

@jskeet jskeet commented Nov 18, 2025

Fixes googleapis/librarian#2796

Note that we may need to reinstate this in the Dockerfile in order to support go-genproto, but we shouldn't need to reinstate the logic in the Bazel parser etc.

We deliberately spot cases where we would have used the old plugin, in order to fail hard instead of just omitting the gRPC output.

This change affects which version of protoc is used for proto-only paths, but running "librarian update-image" using a locally-build container demonstrates that this doesn't affect the generated code.

Fixes googleapis/librarian#2796

Note that we *may* need to reinstate this in the Dockerfile in order
to support go-genproto, but we shouldn't need to reinstate the logic in the
Bazel parser etc.

We deliberately spot cases where we *would* have used the old plugin,
in order to fail hard instead of just omitting the gRPC output.

This change affects which version of protoc is used for proto-only
paths, but running "librarian update-image" using a locally-build
container demonstrates that this doesn't affect the generated code.
@jskeet jskeet requested a review from quartzmo November 18, 2025 08:54
@jskeet jskeet requested review from a team as code owners November 18, 2025 08:54
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @jskeet, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request undertakes a significant cleanup by removing all traces of the legacy protoc and gRPC plugins from the librariangen tool. The primary goal is to eliminate outdated dependencies and enforce the use of modern plugin versions, ensuring a more consistent and maintainable code generation process. While the change might necessitate adjustments for any projects still relying on the old plugin, it ultimately simplifies the build environment and protoc command generation logic.

Highlights

  • Removal of Legacy Protoc Plugin: The protoc-gen-go_v1 plugin and its associated build steps have been completely removed from the Dockerfile, eliminating an outdated dependency.
  • Enforced Migration: The Bazel parser now explicitly errors out if it detects usage of the @io_bazel_rules_go//proto:go_grpc legacy gRPC plugin, preventing its accidental use and pushing towards modern plugin versions.
  • Simplified Protoc Command Building: The logic for constructing protoc commands has been streamlined by removing conditional handling for the legacy gRPC plugin, now consistently using the newer --go_out and --go-grpc_out options.
  • Test Suite Updates: Corresponding test cases and mock configurations have been updated to reflect the removal of the legacy plugin and its related parsing and command-building logic.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request removes the legacy protoc/gRPC plugins, which simplifies the codebase and tooling. The changes are well-executed, removing dead code from the Dockerfile, Go source files, and associated tests. A key improvement is the introduction of a hard failure when the legacy plugin is detected in a BUILD.bazel file, preventing silent misconfigurations. The tests have been updated to reflect this new behavior. My review includes a couple of minor suggestions to improve an error message and strengthen a test case.

}
c.hasLegacyGRPC = strings.Contains(goProtoLibraryBlock, "@io_bazel_rules_go//proto:go_grpc")
if strings.Contains(goProtoLibraryBlock, "@io_bazel_rules_go//proto:go_grpc") {
return nil, fmt.Errorf("librariangen: BUILD.bazel requires legacy gRPC plugin: %s", fp)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The error message requires legacy gRPC plugin could be misinterpreted as a missing dependency. To improve clarity for users who encounter this error, consider rephrasing it to state that the legacy plugin is no longer supported.

Suggested change
return nil, fmt.Errorf("librariangen: BUILD.bazel requires legacy gRPC plugin: %s", fp)
return nil, fmt.Errorf("librariangen: BUILD.bazel uses legacy gRPC plugin (@io_bazel_rules_go//proto:go_grpc) which is no longer supported: %s", fp)

Comment on lines +275 to 278
_, err := Parse(tmpDir)
if err == nil {
t.Error("Parse() succeeded; want error")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

To make this test more robust, it's a good practice to assert not just that an error occurred, but that the correct error occurred. You can check if the error message contains a specific substring related to the legacy plugin. Also, consider using t.Fatal when an error is expected but not found, as it stops the test execution immediately, which is appropriate here.

Suggested change
_, err := Parse(tmpDir)
if err == nil {
t.Error("Parse() succeeded; want error")
}
_, err := Parse(tmpDir)
if err == nil {
t.Fatal("Parse() succeeded; want error")
}
if !strings.Contains(err.Error(), "legacy gRPC plugin") {
t.Errorf("Parse() returned unexpected error: got %v, want substring 'legacy gRPC plugin'", err)
}

@jskeet
Copy link
Contributor Author

jskeet commented Nov 18, 2025

Just noticed there were two failed generations with this code - checking...

@jskeet jskeet added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Nov 18, 2025
@jskeet
Copy link
Contributor Author

jskeet commented Nov 18, 2025

Okay, there are two libraries affected:

  • longrunning, which genuinely has gRPC code in operations.pb.go
  • shopping/type, which doesn't have any services, so we should just be able to remove the compiler line from the go_proto_library rule

@quartzmo Do you think we can migrate https://github.com/googleapis/googleapis/blob/master/google/longrunning/BUILD.bazel? Is there a reason it hasn't already been changed?

@jskeet
Copy link
Contributor Author

jskeet commented Nov 18, 2025

Googlers: I've created cl/833760584 to try to change the BUILD.bazel files here.

@jskeet
Copy link
Contributor Author

jskeet commented Nov 18, 2025

CL submitted. Once that has gone through, I should be able to run my check again. If there are no changes at that point, I'll remove the do-not-merge label.

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

Labels

do not merge Indicates a pull request not ready for merge, due to either quality or timing.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

google-cloud-go: delete legacy gRPC generator from internal/librariangen

1 participant