Skip to content

[SSR Agent] Issue Fix (19826): Migrate process.env to vi.stubEnv in a2a-server tests - #28811

Merged
joneba-google merged 3 commits into
google-gemini:mainfrom
JonE01:ssr-agent-19826
Aug 14, 2026
Merged

joneba-google merged 3 commits into
google-gemini:mainfrom
JonE01:ssr-agent-19826

Conversation

@joneba-google

Copy link
Copy Markdown
Contributor

fixes #19826
Issue URL: #19826

Context & Problem

Test files in packages/a2a-server directly modified process.env instead of using Vitest's vi.stubEnv() and vi.unstubAllEnvs() per project guidelines. Direct assignments and deletions of process.env properties in test setups and test cases can cause environment variables state leakage across tests.

Detailed Changes

The following changes were made to resolve the issue:

  • init.test.ts: Replaced direct assignment to process.env with vi.stubEnv() inside beforeEach, and added an afterEach block to call vi.unstubAllEnvs().
  • app.test.ts: Replaced direct assignments and deletions on process.env with vi.stubEnv() calls, and added vi.unstubAllEnvs() to the existing afterEach hook.
  • config.test.ts: Audited and confirmed that all environment variables are correctly isolated using vi.stubEnv and vi.unstubAllEnvs().

Verification

Linter checks ran successfully on the modified files. Environmental isolation is maintained cleanly across the entire a2a-server test suite.

@joneba-google
joneba-google requested a review from a team as a code owner August 14, 2026 20:56
@gemini-code-assist

Copy link
Copy Markdown
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 addresses issue #19826 by refactoring test suites in the a2a-server package to use Vitest's built-in environment stubbing utilities. By moving away from direct manipulation of process.env, the changes improve test reliability and prevent potential cross-test environment pollution, aligning the codebase with project testing standards.

Highlights

  • Environment Variable Isolation: Replaced direct modifications of process.env with Vitest's vi.stubEnv() to ensure environment variable isolation and prevent state leakage between tests.
  • Test Cleanup: Implemented vi.unstubAllEnvs() in afterEach hooks across affected test files to guarantee a clean environment state after each test execution.
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 the 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 counterproductive. 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.

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. ↩

@github-actions github-actions Bot added the size/s A small PR label Aug 14, 2026
@github-actions

Copy link
Copy Markdown

📊 PR Size: size/S

  • Lines changed: 15
  • Additions: +10
  • Deletions: -5
  • Files changed: 2

@google-cla

google-cla Bot commented Aug 14, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions

Copy link
Copy Markdown

You already have 7 pull requests open. Please work on getting existing PRs merged before opening more.

@github-actions github-actions Bot closed this Aug 14, 2026

@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 refactors environment variable manipulation in tests within packages/a2a-server to use Vitest's vi.stubEnv and vi.unstubAllEnvs instead of directly modifying process.env. The feedback points out that according to the repository style guide, unsetting an environment variable should be done by passing an empty string '' to vi.stubEnv rather than undefined.

Comment thread packages/a2a-server/src/http/app.test.ts Outdated
Comment thread packages/a2a-server/src/http/app.test.ts Outdated
@joneba-google joneba-google reopened this Aug 14, 2026
@gemini-cli gemini-cli Bot added priority/p3 Backlog - a good idea but not currently a priority. area/platform Issues related to Build infra, Release mgmt, Testing, Eval infra, Capacity, Quota mgmt help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support! labels Aug 14, 2026

@adamfweidman adamfweidman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. Please apply suggestions (can do within UI) then merge

…2a-server tests

$fixes google-gemini#19826
Issue URL: google-gemini#19826

### Context & Problem

Test files in `packages/a2a-server` directly modified `process.env` instead of using Vitest's `vi.stubEnv()` and `vi.unstubAllEnvs()` per project guidelines. Direct assignments and deletions of `process.env` properties in test setups and test cases can cause environment variables state leakage across tests.

### Detailed Changes

The following changes were made to resolve the issue:
- **[init.test.ts](file:///usr/local/google/home/joneba/ssr-prototype/gcli-intern-project/tools/caretaker-agent/evals/pr-generation/run_outputs/onboarded_triaged_3.5_flash/agent_environments/issue_19826/tmp/eval/gemini-cli-clone/packages/a2a-server/src/commands/init.test.ts)**: Replaced direct assignment to `process.env` with `vi.stubEnv()` inside `beforeEach`, and added an `afterEach` block to call `vi.unstubAllEnvs()`.
- **[app.test.ts](file:///usr/local/google/home/joneba/ssr-prototype/gcli-intern-project/tools/caretaker-agent/evals/pr-generation/run_outputs/onboarded_triaged_3.5_flash/agent_environments/issue_19826/tmp/eval/gemini-cli-clone/packages/a2a-server/src/http/app.test.ts)**: Replaced direct assignments and deletions on `process.env` with `vi.stubEnv()` calls, and added `vi.unstubAllEnvs()` to the existing `afterEach` hook.
- **[config.test.ts](file:///usr/local/google/home/joneba/ssr-prototype/gcli-intern-project/tools/caretaker-agent/evals/pr-generation/run_outputs/onboarded_triaged_3.5_flash/agent_environments/issue_19826/tmp/eval/gemini-cli-clone/packages/a2a-server/src/config/config.test.ts)**: Audited and confirmed that all environment variables are correctly isolated using `vi.stubEnv` and `vi.unstubAllEnvs()`.

### Verification

Linter checks ran successfully on the modified files. Environmental isolation is maintained cleanly across the entire a2a-server test suite.
@joneba-google

Copy link
Copy Markdown
Contributor Author

/gemini review

@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 refactors the test files in packages/a2a-server to use Vitest's vi.stubEnv and vi.unstubAllEnvs instead of directly modifying process.env. The review feedback correctly points out that, according to the repository style guide, environment variables should be unset using an empty string '' rather than undefined.

vi.spyOn(commandRegistry, 'get').mockReturnValue(mockCommand);

delete process.env['CODER_AGENT_WORKSPACE_PATH'];
vi.stubEnv('CODER_AGENT_WORKSPACE_PATH', 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.

high

According to the repository style guide, to "unset" an environment variable when using vi.stubEnv, you should use an empty string '' instead of undefined.

Suggested change
vi.stubEnv('CODER_AGENT_WORKSPACE_PATH', undefined);
vi.stubEnv('CODER_AGENT_WORKSPACE_PATH', '');
References
  1. To "unset" a variable, use an empty string vi.stubEnv('NAME', ''). (link)

vi.spyOn(commandRegistry, 'get').mockReturnValue(mockWorkspaceCommand);

delete process.env['CODER_AGENT_WORKSPACE_PATH'];
vi.stubEnv('CODER_AGENT_WORKSPACE_PATH', 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.

high

According to the repository style guide, to "unset" an environment variable when using vi.stubEnv, you should use an empty string '' instead of undefined.

Suggested change
vi.stubEnv('CODER_AGENT_WORKSPACE_PATH', undefined);
vi.stubEnv('CODER_AGENT_WORKSPACE_PATH', '');
References
  1. To "unset" a variable, use an empty string vi.stubEnv('NAME', ''). (link)

joneba-google and others added 2 commits August 14, 2026 19:20
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

@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 refactors the test files init.test.ts and app.test.ts to use Vitest's vi.stubEnv and vi.unstubAllEnvs instead of directly manipulating process.env. Feedback was provided to align with the repository style guide by using an empty string vi.stubEnv('NAME', '') instead of undefined to unset environment variables.

vi.spyOn(commandRegistry, 'get').mockReturnValue(mockCommand);

delete process.env['CODER_AGENT_WORKSPACE_PATH'];
vi.stubEnv('CODER_AGENT_WORKSPACE_PATH', '');

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.

high

According to the repository style guide, to "unset" an environment variable, you should use an empty string vi.stubEnv('NAME', '') instead of passing undefined.

Suggested change
vi.stubEnv('CODER_AGENT_WORKSPACE_PATH', '');
vi.stubEnv('CODER_AGENT_WORKSPACE_PATH', '');
References
  1. To "unset" a variable, use an empty string vi.stubEnv('NAME', ''). (link)

vi.spyOn(commandRegistry, 'get').mockReturnValue(mockWorkspaceCommand);

delete process.env['CODER_AGENT_WORKSPACE_PATH'];
vi.stubEnv('CODER_AGENT_WORKSPACE_PATH', '');

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.

high

According to the repository style guide, to "unset" an environment variable, you should use an empty string vi.stubEnv('NAME', '') instead of passing undefined.

Suggested change
vi.stubEnv('CODER_AGENT_WORKSPACE_PATH', '');
vi.stubEnv('CODER_AGENT_WORKSPACE_PATH', '');
References
  1. To "unset" a variable, use an empty string vi.stubEnv('NAME', ''). (link)

@joneba-google
joneba-google added this pull request to the merge queue Aug 14, 2026
Merged via the queue into google-gemini:main with commit 2a87e7b Aug 14, 2026
33 checks passed
@joneba-google
joneba-google deleted the ssr-agent-19826 branch August 14, 2026 23:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/platform Issues related to Build infra, Release mgmt, Testing, Eval infra, Capacity, Quota mgmt help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support! priority/p3 Backlog - a good idea but not currently a priority. size/s A small PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(a2a-server): migrate process.env to vi.stubEnv() per GEMINI.md conventions

2 participants