Skip to content

No public description - #22

Closed
wanlin31 wants to merge 1 commit into
mainfrom
copybara/985463163
Closed

wanlin31 wants to merge 1 commit into
mainfrom
copybara/985463163

Conversation

@wanlin31

Copy link
Copy Markdown

No public description

PiperOrigin-RevId: 985463163

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

Copy link
Copy Markdown

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 rewrites the experimental Gemini API CLI from a Bun/Node.js-based project to a Go-based CLI using Cobra and the Speakeasy SDK. The review feedback identifies two critical issues: first, the required flag validation in guardRequiredFlags fails to detect missing slice or array flags because their default value is represented as "[]" rather than ""; second, a type mismatch compile error exists in internal/cli/custom/tts.go where *int64 pointer fields are assigned directly to int variables without explicit casting.

Comment on lines +163 to +169
c.LocalFlags().VisitAll(func(f *pflag.Flag) {
required := len(f.Annotations[flagutil.AnnotationRequired]) > 0
blank := f.Value.Type() == "string" && strings.TrimSpace(f.Value.String()) == ""
if required && (blank || (!f.Changed && f.DefValue == "")) {
missing = append(missing, "--"+f.Name)
}
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The current required flag validation in guardRequiredFlags only checks if a flag is of type string and is blank, or if it is not changed and has an empty default value (f.DefValue == ""). However, for required slice or array flags (like stringSlice or stringArray), the default value in Cobra is represented as "[]" rather than "". As a result, required slice/array flags that are omitted by the user are not detected as missing, which can lead to invalid API requests.

To fix this, we should check if the flag is unset (not changed) and has an empty string or empty slice representation as its value.

Suggested change
c.LocalFlags().VisitAll(func(f *pflag.Flag) {
required := len(f.Annotations[flagutil.AnnotationRequired]) > 0
blank := f.Value.Type() == "string" && strings.TrimSpace(f.Value.String()) == ""
if required && (blank || (!f.Changed && f.DefValue == "")) {
missing = append(missing, "--"+f.Name)
}
})
c.LocalFlags().VisitAll(func(f *pflag.Flag) {
required := len(f.Annotations[flagutil.AnnotationRequired]) > 0
if !required {
return
}
isDefault := !f.Changed
isEmpty := f.Value.String() == "" || f.Value.String() == "[]"
if (isDefault && isEmpty) || (f.Value.Type() == "string" && strings.TrimSpace(f.Value.String()) == "") {
missing = append(missing, "--"+f.Name)
}
})

Comment on lines +271 to +280
blockMIME, blockChannels, blockRate := "", 0, 0
if ac.MimeType != nil {
blockMIME = string(*ac.MimeType)
}
if ac.Channels != nil {
blockChannels = *ac.Channels
}
if ac.SampleRate != nil {
blockRate = *ac.SampleRate
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

In Speakeasy generated Go SDKs, integer fields in schemas (like channels and sample_rate) are typically represented as *int64 pointers. Since blockChannels and blockRate are inferred as int (from the 0 literal), directly assigning *ac.Channels or *ac.SampleRate to them will cause a type mismatch compile error.

To prevent this, we should explicitly cast the dereferenced values to int.

Suggested change
blockMIME, blockChannels, blockRate := "", 0, 0
if ac.MimeType != nil {
blockMIME = string(*ac.MimeType)
}
if ac.Channels != nil {
blockChannels = *ac.Channels
}
if ac.SampleRate != nil {
blockRate = *ac.SampleRate
}
blockMIME, blockChannels, blockRate := "", 0, 0
if ac.MimeType != nil {
blockMIME = string(*ac.MimeType)
}
if ac.Channels != nil {
blockChannels = int(*ac.Channels)
}
if ac.SampleRate != nil {
blockRate = int(*ac.SampleRate)
}

@BenJomy

BenJomy commented Sep 22, 2026 via email

Copy link
Copy Markdown

@gemini-code-assist

Copy link
Copy Markdown

Hello BenJomy, I apologize for the confusion. The email you received is an automated notification from the Gemini Code Assist bot regarding the pull request you are currently reviewing. It summarizes the changes in the pull request and provides specific code review feedback to help improve the code quality and ensure it meets project standards. You can safely ignore the email if you have already reviewed the pull request or if you do not need to take any action on it.

@wanlin31 wanlin31 closed this Sep 22, 2026
@wanlin31
wanlin31 deleted the copybara/985463163 branch September 22, 2026 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants