Skip to content

fix(patch): cherry-pick 936f624 to release/v0.33.0-preview.5-pr-21702 to patch version v0.33.0-preview.5 and create version 0.33.0-preview.6#21742

Merged
gsquared94 merged 1 commit intorelease/v0.33.0-preview.5-pr-21702from
hotfix/v0.33.0-preview.5/0.33.0-preview.6/preview/cherry-pick-936f624/pr-21702
Mar 9, 2026
Merged

fix(patch): cherry-pick 936f624 to release/v0.33.0-preview.5-pr-21702 to patch version v0.33.0-preview.5 and create version 0.33.0-preview.6#21742
gsquared94 merged 1 commit intorelease/v0.33.0-preview.5-pr-21702from
hotfix/v0.33.0-preview.5/0.33.0-preview.6/preview/cherry-pick-936f624/pr-21702

Conversation

@gemini-cli-robot
Copy link
Collaborator

This PR automatically cherry-picks commit 936f624 to patch version v0.33.0-preview.5 in the preview release to create version 0.33.0-preview.6.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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 enhances the error handling mechanism by introducing robust JSON sanitization to mitigate issues caused by Server-Sent Events (SSE) stream corruption. By cleaning up malformed JSON strings and domain names before parsing, the system can now reliably interpret Google API errors, including quota and validation messages, even when the underlying data is slightly corrupted. This ensures more accurate error classification and a more resilient application experience.

Highlights

  • JSON Sanitization: A new utility function, "sanitizeJsonString", was introduced to clean up JSON strings corrupted by Server-Sent Events (SSE) stream parsing, specifically targeting stray commas.
  • Error Parsing Robustness: The "parseGoogleApiError" function and its helpers were updated to use the new sanitization logic, ensuring that Google API errors with corrupted JSON messages or data can be correctly parsed.
  • Domain Name Sanitization: A new "isCloudCodeDomain" function was added to sanitize domain strings before comparison, preventing issues with SSE-corrupted domain names in quota and validation error classification.
  • Expanded Test Coverage: New unit tests were added to "googleErrors.test.ts" and "googleQuotaErrors.test.ts" to specifically cover scenarios involving SSE-corrupted JSON and domain strings, validating the robustness of the error parsing and classification.
Changelog
  • packages/core/src/utils/googleErrors.test.ts
    • Added a test case to parse a gaxios error with SSE-corrupted JSON containing stray commas.
    • Added a test case to parse a gaxios error with SSE-corrupted JSON in "response.data".
  • packages/core/src/utils/googleErrors.ts
    • Added "sanitizeJsonString" function to remove duplicate commas from JSON strings.
    • Modified "parseGoogleApiError" to use "sanitizeJsonString" when parsing string errors.
    • Modified "fromGaxiosError", "fromApiError" to use "sanitizeJsonString" when parsing JSON data.
  • packages/core/src/utils/googleQuotaErrors.test.ts
    • Added a test case to return "TerminalQuotaError" for Cloud Code "QUOTA_EXHAUSTED" with an SSE-corrupted domain.
    • Added a test case to return "ValidationRequiredError" with an SSE-corrupted domain.
  • packages/core/src/utils/googleQuotaErrors.ts
    • Added "isCloudCodeDomain" function to check if a domain belongs to a Cloud Code API endpoint after sanitizing it.
    • Updated "classifyValidationRequiredError" and "classifyGoogleError" to use "isCloudCodeDomain" for domain checks.
Activity
  • No human activity has been recorded for this pull request.
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.

@gemini-cli gemini-cli bot added the status/need-issue Pull requests that need to have an associated issue. label Mar 9, 2026
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 cherry-picks a fix for handling corrupted Google API error responses, particularly those from SSE streams that may contain stray commas. The changes introduce a sanitizeJsonString function to clean up malformed JSON before parsing and a isCloudCodeDomain function to robustly check domain names even if they contain stray characters. The approach is sound and is accompanied by good test coverage. I have one suggestion to make the domain checking even more robust by handling trailing dots in FQDNs.

* domain string before comparing.
*/
function isCloudCodeDomain(domain: string): boolean {
const sanitized = domain.replace(/[^a-zA-Z0-9.-]/g, '');
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The current sanitization logic correctly handles stray characters like commas but doesn't account for a valid trailing dot in a Fully Qualified Domain Name (FQDN). If a domain is passed as cloudcode-pa.googleapis.com., it will not be matched against the CLOUDCODE_DOMAINS list, leading to incorrect error classification. To make this more robust, we should also normalize the domain by removing any trailing dot.

Suggested change
const sanitized = domain.replace(/[^a-zA-Z0-9.-]/g, '');
const sanitized = domain.replace(/[^a-zA-Z0-9.-]/g, '').replace(/\.$/, '');

@github-actions
Copy link

github-actions bot commented Mar 9, 2026

Size Change: +292 B (0%)

Total Size: 25.9 MB

ℹ️ View Unchanged
Filename Size Change
./bundle/gemini.js 25.4 MB +292 B (0%)
./bundle/node_modules/@google/gemini-cli-devtools/dist/client/main.js 221 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/_client-assets.js 227 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/index.js 11.5 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/types.js 132 B 0 B
./bundle/sandbox-macos-permissive-open.sb 890 B 0 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB 0 B
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB 0 B
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB 0 B
./bundle/sandbox-macos-strict-open.sb 4.82 kB 0 B
./bundle/sandbox-macos-strict-proxied.sb 5.02 kB 0 B

compressed-size-action

@gsquared94 gsquared94 enabled auto-merge (squash) March 9, 2026 18:30
@gsquared94 gsquared94 merged commit 94b3a25 into release/v0.33.0-preview.5-pr-21702 Mar 9, 2026
28 checks passed
@gsquared94 gsquared94 deleted the hotfix/v0.33.0-preview.5/0.33.0-preview.6/preview/cherry-pick-936f624/pr-21702 branch March 9, 2026 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status/need-issue Pull requests that need to have an associated issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants