Skip to content

fix: add logic and cmd to update Transports in api.go#3940

Open
zhumin8 wants to merge 3 commits intomainfrom
trans-step-3
Open

fix: add logic and cmd to update Transports in api.go#3940
zhumin8 wants to merge 3 commits intomainfrom
trans-step-3

Conversation

@zhumin8
Copy link
Contributor

@zhumin8 zhumin8 commented Feb 6, 2026

Add logic and command to loop through API list in api.go and update transport info based BUILD.bazel from googleapis.
This is intended to be used during migration, so for simplicity passing path to googleapis dir to command (we assume transport info does not change other than new libs).

For #3775

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 introduces a new command and associated logic to update transport information in internal/serviceconfig/api.go by parsing BUILD.bazel files. The approach of using Go's AST manipulation capabilities is sound. However, I've identified a critical issue that causes the generation of non-compilable code due to incorrect assumptions about available language constants. Additionally, there's a minor bug in the transport simplification logic and a test that doesn't adhere to the project's testing style guide. My review includes suggestions to address these points.

@zhumin8 zhumin8 changed the title fix: add logic and cmd to update Transports fix: add logic and cmd to update Transports in api.go Feb 6, 2026
@codecov
Copy link

codecov bot commented Feb 6, 2026

Codecov Report

❌ Patch coverage is 78.83212% with 29 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.25%. Comparing base (9d04c44) to head (d150485).

Files with missing lines Patch % Lines
internal/importconfig/update_transports.go 78.83% 17 Missing and 12 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3940      +/-   ##
==========================================
- Coverage   83.35%   83.25%   -0.10%     
==========================================
  Files          69       70       +1     
  Lines        6188     6325     +137     
==========================================
+ Hits         5158     5266     +108     
- Misses        671      688      +17     
- Partials      359      371      +12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@zhumin8 zhumin8 marked this pull request as ready for review February 6, 2026 19:51
@zhumin8 zhumin8 requested a review from a team as a code owner February 6, 2026 19:51
// limitations under the License.

// Package importconfig provides commands for importing configurations.
package importconfig
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need a command to do this? If this is part of the migration, we should write code in tool/cmd/migrate.

return fmt.Errorf("failed to parse %s: %w", apiGoPath, err)
}

apisSlice := findAPIsSlice(astFile)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you write a comments for this function?

}
transports := readTransports(googleapisDir, path)
if len(transports) == 0 || (len(transports) == 1 && transports["all"] == "grpc+rest") {
if transportsIdx != -1 {
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this line mean?

return
}
if diff := cmp.Diff(test.want, got); diff != "" {
if diff := cmp.Diff(test.want, got, cmpopts.IgnoreFields(API{}, "Transports")); diff != "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add a comment on why we need to ignore transport?


func TestUpdateTransportsCommand(t *testing.T) {
cmd := updateTransportsCommand()
ctx := context.Background()
Copy link
Contributor

Choose a reason for hiding this comment

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

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