Pool Gemini subscriptions through Prism - #32
Conversation
🤖 CodeAnt AI — Review Status
|
Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| for index := 0; index < len(args); index++ { | ||
| argument := args[index] | ||
| switch { | ||
| case argument == "--": | ||
| return options, account, append(passthrough, args[index:]...), nil | ||
| case argument == "--profile": | ||
| if options.profileSet { | ||
| return commonOptions{}, "", nil, errors.New("--profile may be specified only once") | ||
| } | ||
| index++ | ||
| if index >= len(args) || strings.TrimSpace(args[index]) == "" || args[index] == "--" { | ||
| return commonOptions{}, "", nil, errors.New("--profile requires a value") | ||
| } | ||
| options.profile = strings.TrimSpace(args[index]) | ||
| options.profileSet = true | ||
| case strings.HasPrefix(argument, "--profile="): | ||
| if options.profileSet { | ||
| return commonOptions{}, "", nil, errors.New("--profile may be specified only once") | ||
| } | ||
| options.profile = strings.TrimSpace(strings.TrimPrefix(argument, "--profile=")) | ||
| if options.profile == "" { | ||
| return commonOptions{}, "", nil, errors.New("--profile requires a value") | ||
| } | ||
| options.profileSet = true | ||
| case argument == "--account": | ||
| if account != "" { | ||
| return commonOptions{}, "", nil, errors.New("--account may be specified only once") | ||
| } | ||
| index++ | ||
| if index >= len(args) || strings.TrimSpace(args[index]) == "" || args[index] == "--" { | ||
| return commonOptions{}, "", nil, errors.New("--account requires a value") | ||
| } | ||
| account = strings.TrimSpace(args[index]) | ||
| case strings.HasPrefix(argument, "--account="): | ||
| if account != "" { | ||
| return commonOptions{}, "", nil, errors.New("--account may be specified only once") | ||
| } | ||
| account = strings.TrimSpace(strings.TrimPrefix(argument, "--account=")) | ||
| if account == "" { | ||
| return commonOptions{}, "", nil, errors.New("--account requires a value") | ||
| } | ||
| default: | ||
| passthrough = append(passthrough, argument) | ||
| } | ||
| filtered = append(filtered, entry) | ||
| } | ||
| return filtered | ||
| } | ||
|
|
||
| func parseGeminiOptions(args []string) (string, []string, error) { | ||
| account, passthrough, err := parseClaudeOptions(args) | ||
| if err != nil { | ||
| return "", nil, err | ||
| } | ||
| return account, passthrough, nil | ||
| return options, account, passthrough, nil |
There was a problem hiding this comment.
Suggestion: parseGeminiOptions consumes every --profile and --account token before --, regardless of whether it is intended for the Gemini CLI. For example, a prompt or another CLI argument whose value is --profile will be interpreted as Prism's profile flag and removed from the child process arguments, causing valid Gemini CLI invocations to fail or behave differently. Restrict Prism option parsing to the owned option position or require -- before passthrough arguments. [logic error]
Severity Level: Major ⚠️
- ❌ Gemini prompt invocations collide with Prism-owned flags.
- ⚠️ Official CLI arguments can be silently removed.Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** internal/cli/gemini.go
**Line:** 159:204
**Comment:**
*Logic Error: `parseGeminiOptions` consumes every `--profile` and `--account` token before `--`, regardless of whether it is intended for the Gemini CLI. For example, a prompt or another CLI argument whose value is `--profile` will be interpreted as Prism's profile flag and removed from the child process arguments, causing valid Gemini CLI invocations to fail or behave differently. Restrict Prism option parsing to the owned option position or require `--` before passthrough arguments.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix| encoded, err := readSecret() | ||
| if err != nil { | ||
| return Bundle{}, errors.New("Antigravity login was not found; sign in with 'agy' first") | ||
| } |
There was a problem hiding this comment.
Suggestion: All keyring failures are reported as a missing login. Permission failures, an unavailable Secret Service or D-Bus session, and other backend errors are therefore converted into incorrect recovery instructions telling the user to sign in with agy, even when a valid login exists. Preserve or wrap the underlying error and only use the missing-login message for keyring.ErrNotFound. [possible bug]
Severity Level: Major ⚠️
- ❌ Valid Antigravity imports fail under keyring outages.
- ⚠️ Recovery instructions incorrectly request reauthentication.Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** internal/gemini/antigravity.go
**Line:** 40:43
**Comment:**
*Possible Bug: All keyring failures are reported as a missing login. Permission failures, an unavailable Secret Service or D-Bus session, and other backend errors are therefore converted into incorrect recovery instructions telling the user to sign in with `agy`, even when a valid login exists. Preserve or wrap the underlying error and only use the missing-login message for `keyring.ErrNotFound`.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix| return Bundle{ | ||
| AccessToken: login.Token.AccessToken, | ||
| RefreshToken: login.Token.RefreshToken, | ||
| ProjectID: projectID, | ||
| Email: email, | ||
| Alias: alias, | ||
| ExpiresAt: login.Token.Expiry.UnixMilli(), | ||
| AuthMethod: "antigravity", | ||
| UserAgent: "antigravity/cli/" + version, | ||
| }, nil |
There was a problem hiding this comment.
Suggestion: Imported Gemini bundles omit AccountID, even though the normal Gemini OAuth flow populates it with the Code Assist project ID. The saved Antigravity credential therefore has a different identity shape and may not be deduplicated or associated correctly by Prism; populate the same account identifier when constructing the imported bundle. [api mismatch]
Severity Level: Major ⚠️
- ⚠️ Imported accounts omit Gemini account identity.
- ⚠️ Deduplication may differ from OAuth accounts.Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** internal/gemini/antigravity.go
**Line:** 82:91
**Comment:**
*Api Mismatch: Imported Gemini bundles omit `AccountID`, even though the normal Gemini OAuth flow populates it with the Code Assist project ID. The saved Antigravity credential therefore has a different identity shape and may not be deduplicated or associated correctly by Prism; populate the same account identifier when constructing the imported bundle.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix| func (h *defaultHandler) PathExists(path ObjectPath) bool { | ||
| _, ok := h.objects[path] | ||
| return ok | ||
| } |
There was a problem hiding this comment.
Suggestion: PathExists reads the shared object map without taking the handler read lock, even though callers use it while exports and unexports can concurrently add or delete entries. This creates a data race and can produce inconsistent check-then-add or check-then-delete behavior. [race condition]
Severity Level: Major ⚠️
- ❌ Concurrent export operations can trigger map races.
- ⚠️ Dynamic interface registration may observe inconsistent state.Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** vendor/github.com/godbus/dbus/v5/default_handler.go
**Line:** 41:44
**Comment:**
*Race Condition: `PathExists` reads the shared object map without taking the handler read lock, even though callers use it while exports and unexports can concurrently add or delete entries. This creates a data race and can produce inconsistent check-then-add or check-then-delete behavior.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix| if after, ok := strings.CutPrefix(string(obj), p); ok { | ||
| name, _, _ := strings.Cut(after, "/") |
There was a problem hiding this comment.
Suggestion: introspectPath iterates over h.objects without holding the handler lock, while AddObject and DeleteObject mutate the same map under that lock. Concurrent introspection and export/unexport operations can trigger a Go concurrent map iteration/write panic and are reported by the race detector. [race condition]
Severity Level: Critical 🚨
- ❌ Concurrent introspection can crash the D-Bus process.
- ⚠️ Runtime export and unexport operations become unsafe.Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** vendor/github.com/godbus/dbus/v5/default_handler.go
**Line:** 55:56
**Comment:**
*Race Condition: `introspectPath` iterates over `h.objects` without holding the handler lock, while `AddObject` and `DeleteObject` mutate the same map under that lock. Concurrent introspection and export/unexport operations can trigger a Go concurrent map iteration/write panic and are reported by the race detector.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix| if hlen+t.rdr.BodyLen+16 > 1<<27 { | ||
| return nil, InvalidMessageError("message is too long") | ||
| } |
There was a problem hiding this comment.
Suggestion: The message-size check performs the addition using uint32 values before comparing with the 128 MiB limit. Malicious header and body lengths can overflow that sum, bypass the limit, and then cause make([]byte, t.rdr.BodyLen) or the subsequent read to allocate or process an excessively large message. [possible bug]
Severity Level: Critical 🚨
- ❌ Malformed D-Bus messages can bypass size limits.
- ❌ Excessive allocations can terminate the process through memory exhaustion.Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** vendor/github.com/godbus/dbus/v5/transport_unix.go
**Line:** 153:155
**Comment:**
*Possible Bug: The message-size check performs the addition using `uint32` values before comparing with the 128 MiB limit. Malicious header and body lengths can overflow that sum, bypass the limit, and then cause `make([]byte, t.rdr.BodyLen)` or the subsequent read to allocate or process an excessively large message.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix| fds, err := syscall.ParseUnixRights(&scms[0]) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| dec.Reset(r, order, fds) |
There was a problem hiding this comment.
Suggestion: File descriptors parsed from ancillary data are not closed on any subsequent error path, including unsupported FD passing, invalid body decoding, or invalid FD indices. A peer can repeatedly send malformed messages with descriptors and exhaust the process file-descriptor limit. [resource leak]
Severity Level: Critical 🚨
- ❌ Malformed FD messages can exhaust process descriptors.
- ⚠️ Subsequent D-Bus connections and file operations may fail.Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** vendor/github.com/godbus/dbus/v5/transport_unix.go
**Line:** 205:209
**Comment:**
*Resource Leak: File descriptors parsed from ancillary data are not closed on any subsequent error path, including unsupported FD passing, invalid body decoding, or invalid FD indices. A peer can repeatedly send malformed messages with descriptors and exhaust the process file-descriptor limit.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
CodeAnt Nitpicks2 code suggestions1. Valid single-type signatures are reported as non-single while invalid signatures may be reported as single.Incorrect condition logic · 2. Prompt handling leaks registered D-Bus signal channels across operations.Resource leak · |
User description
Summary
Verification
go test -mod=vendor ./...go test -mod=vendor -race ./...go vet -mod=vendor ./...CodeAnt-AI Description
Pool Gemini subscription accounts through Prism
What Changed
prism gemini auth import--accountImpact
✅ Gemini requests rotate across subscription accounts✅ Fewer subscription setup steps✅ Clearer Gemini account and quota visibility💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.