Skip to content

JSONRPC test client should clear tool-specific env vars for full isolation #401

@karthiknadig

Description

@karthiknadig

Summary

The JSONRPC integration test client (crates/pet/tests/jsonrpc_client.rs, line ~99) sets PATH to empty to isolate the server from the host. However, tool-specific environment variables are not cleared.

Details

Variables like CONDA_EXE, PYENV_ROOT, UV_PYTHON_INSTALL_DIR, WORKON_HOME, PIPENV_VENV_IN_PROJECT, POETRY_VIRTUALENVS_PATH, and others could leak host state into the test environment, causing non-deterministic test results depending on the developer's machine.

Proposed Fix

Clear all known tool-specific environment variables in PetJsonRpcClient::spawn() alongside the existing PATH clearing. Consider a blocklist approach:

.env("CONDA_EXE", "")
.env("PYENV_ROOT", "")
.env("UV_PYTHON_INSTALL_DIR", "")
.env("WORKON_HOME", "")
.env("PIPENV_VENV_IN_PROJECT", "")
.env("POETRY_VIRTUALENVS_PATH", "")
.env("VIRTUAL_ENV", "")

Impact

Low — current tests pass, but results may vary across developer machines with different tool installations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions