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
Conversation
Summary of ChangesHello, 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
Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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, ''); |
There was a problem hiding this comment.
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.
| const sanitized = domain.replace(/[^a-zA-Z0-9.-]/g, ''); | |
| const sanitized = domain.replace(/[^a-zA-Z0-9.-]/g, '').replace(/\.$/, ''); |
|
Size Change: +292 B (0%) Total Size: 25.9 MB ℹ️ View Unchanged
|
94b3a25
into
release/v0.33.0-preview.5-pr-21702
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.