Skip to content

Cleanup: Redundant identical branches in generated code (BackendVertexAI vs fallback) #761

@KuroseReza

Description

@KuroseReza

While reading through the SDK, I noticed several places in the generated code where the conditional branches for BackendVertexAI and the default fallback contain completely identical logic.

For example, in models.go (around line 4557):

if m.apiClient.ClientConfig().Backend == BackendVertexAI {
 path, err = InternalFormatMap("{model}:generateContent", urlParams)
} else {
 path, err = InternalFormatMap("{model}:generateContent", urlParams)
}

This exact pattern repeats across other generated API methods too.

I'd normally just open a PR to clean this up, but I noticed the file headers (// Code generated by the Google Gen AI SDK generator DO NOT EDIT.) and past PRs (like #562) which suggest the generator source lives upstream and is synced here via Copybara.

Could you folks look into updating the internal generator templates to remove these redundant branches? Or, if the generator repo is public, let me know where it is and I'd be happy to submit a PR there.

Metadata

Metadata

Labels

api:gemini-apiIssues related to Gemini APIpriority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions