Skip to content

fix(gaxios): prevent comma corruption when draining stream error responses - #8778

Closed
pearigee wants to merge 1 commit into
googleapis:mainfrom
jerrylin3321:jerrylin-fix-comma-corruption-2
Closed

pearigee wants to merge 1 commit into
googleapis:mainfrom
jerrylin3321:jerrylin-fix-comma-corruption-2

Conversation

@pearigee

Copy link
Copy Markdown
Contributor

With this fix, we are hoping to address google-gemini/gemini-cli#21884 and #8768.

Credit to @jerrylin3321 for originally creating this branch. We are creating a PR to add a few additional changes on top of it.

@pearigee
pearigee requested a review from a team as a code owner June 29, 2026 21:01

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

Copy link
Copy Markdown
Contributor

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 improves stream error response handling in Gaxios by ensuring chunks are joined correctly without comma corruption, and adds a corresponding test. It also clears proxy environment variables before MTLS tests. The reviewer pointed out that modifying these environment variables without restoring them could cause test pollution, and suggested backing up and restoring them in an afterEach block.

Comment on lines +1328 to +1335
beforeEach(() => {
setEnv({
HTTP_PROXY: undefined,
HTTPS_PROXY: undefined,
http_proxy: undefined,
https_proxy: undefined,
});
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Modifying global environment variables in beforeEach without restoring them can lead to test pollution and flaky tests in other parts of the test suite. It is highly recommended to back up the original environment variables and restore them in an afterEach block.

Suggested change
beforeEach(() => {
setEnv({
HTTP_PROXY: undefined,
HTTPS_PROXY: undefined,
http_proxy: undefined,
https_proxy: undefined,
});
});
let originalEnv: Record<string, string | undefined>;
beforeEach(() => {
originalEnv = {
HTTP_PROXY: process.env.HTTP_PROXY,
HTTPS_PROXY: process.env.HTTPS_PROXY,
http_proxy: process.env.http_proxy,
https_proxy: process.env.https_proxy,
};
setEnv({
HTTP_PROXY: undefined,
HTTPS_PROXY: undefined,
http_proxy: undefined,
https_proxy: undefined,
});
});
afterEach(() => {
setEnv(originalEnv);
});

@pearigee pearigee closed this Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant