Skip to content

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

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

fix(patch): cherry-pick 936f624 to release/v0.33.0-preview.9-pr-21702 to patch version v0.33.0-preview.9 and create version 0.33.0-preview.10#21800
galz10 merged 1 commit intorelease/v0.33.0-preview.9-pr-21702from
hotfix/v0.33.0-preview.9/0.33.0-preview.10/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.9 in the preview release to create version 0.33.0-preview.10.

@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 robustness of Google API error parsing by introducing mechanisms to handle JSON corruption caused by Server-Sent Events (SSE) serialization. It ensures that error messages and domain information can be correctly interpreted despite the presence of stray characters, thereby improving the reliability of error classification and user feedback.

Highlights

  • Robust Error Parsing: Implemented a new sanitizeJsonString utility to clean up JSON strings that may be corrupted by Server-Sent Events (SSE) serialization, specifically addressing stray commas.
  • Enhanced Google API Error Handling: Integrated the sanitizeJsonString function into parseGoogleApiError to ensure reliable parsing of error messages, even when they contain SSE-induced corruption.
  • Improved Quota Error Domain Validation: Introduced isCloudCodeDomain to sanitize domain strings before comparison, preventing issues with quota and validation error classification due to corrupted domain information.
  • Comprehensive Test Coverage: Added new test cases in googleErrors.test.ts and googleQuotaErrors.test.ts to validate the parsing and classification of errors with various forms of SSE-corrupted JSON and domain strings.
Changelog
  • packages/core/src/utils/googleErrors.test.ts
    • Added new test cases to verify the parsing of gaxios errors containing SSE-corrupted JSON, both in the message path and response data.
  • packages/core/src/utils/googleErrors.ts
    • Introduced a sanitizeJsonString function to remove duplicate commas and whitespace that can be injected by SSE stream parsing.
    • Applied sanitizeJsonString to all JSON parsing attempts within parseGoogleApiError to handle corrupted input.
  • packages/core/src/utils/googleQuotaErrors.test.ts
    • Added test cases to confirm that classifyGoogleError correctly identifies TerminalQuotaError and ValidationRequiredError even when the error domain is corrupted by SSE serialization.
  • packages/core/src/utils/googleQuotaErrors.ts
    • Implemented isCloudCodeDomain to sanitize domain strings by removing non-alphanumeric characters before checking if they belong to Cloud Code API endpoints.
    • Updated classifyValidationRequiredError and classifyGoogleError to utilize the new isCloudCodeDomain function for more resilient domain validation.
Activity
  • The pull request was automatically created by gemini-cli-robot to cherry-pick commit 936f624 to the release/v0.33.0-preview.9-pr-21702 branch, patching version v0.33.0-preview.9 and creating version 0.33.0-preview.10.
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.

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 from SSE streams. The changes introduce sanitization logic to handle stray commas in JSON responses and corrupted characters in domain name strings within the error details.

My review focuses on the robustness of the new sanitization logic. I've found a potential issue in the sanitizeJsonString function where certain patterns of corruption could still result in invalid JSON. I've provided a suggestion for a more robust and efficient implementation. The other changes, including the domain sanitization and the new tests, look good.

Comment on lines +20 to +30
function sanitizeJsonString(jsonStr: string): string {
// Match a comma, optional whitespace/newlines, then another comma.
// Replace with just a comma + the captured whitespace.
// Loop to handle cases like `,,,` which would otherwise become `,,` on a single pass.
let prev: string;
do {
prev = jsonStr;
jsonStr = jsonStr.replace(/,(\s*),/g, ',$1');
} while (jsonStr !== prev);
return jsonStr;
}
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 implementation is not fully robust. For an input with multiple stray commas separated by whitespace, like {"key": 1, , , 2}, it can produce invalid JSON. The issue is that preserving whitespace between commas can lead to an invalid structure.

A more robust and efficient solution is to use a single regular expression to replace any sequence of commas and intermittent whitespace with a single comma. This avoids the loop and correctly sanitizes more complex corruption patterns.

function sanitizeJsonString(jsonStr: string): string {
  // This regex finds a comma followed by one or more groups of
  // (optional whitespace and another comma). It replaces the entire
  // sequence with a single comma. This handles cases like `, ,` or `,,,`
  // in a single pass without a loop.
  return jsonStr.replace(/,(\s*,)+/g, ',');
}

@github-actions
Copy link

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

@gemini-cli gemini-cli bot added the status/need-issue Pull requests that need to have an associated issue. label Mar 10, 2026
@galz10 galz10 merged commit c18aae3 into release/v0.33.0-preview.9-pr-21702 Mar 10, 2026
28 checks passed
@galz10 galz10 deleted the hotfix/v0.33.0-preview.9/0.33.0-preview.10/preview/cherry-pick-936f624/pr-21702 branch March 10, 2026 01:26
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.

3 participants