Skip to content

fix: isolate mirror tests from host env to prevent API key leak (#522)#573

Open
ElegantLin wants to merge 1 commit into
mainfrom
fix/522-test-env-leak
Open

fix: isolate mirror tests from host env to prevent API key leak (#522)#573
ElegantLin wants to merge 1 commit into
mainfrom
fix/522-test-env-leak

Conversation

@ElegantLin
Copy link
Copy Markdown

@ElegantLin ElegantLin commented May 27, 2026

Summary

  • TestAutoInheritEnvBidirectionalMirror called auto_inherit_env() without clearing os.environ, so real API keys (e.g. GEMINI_API_KEY) on the host leaked into the test dict
  • Assertion failures then printed the real key value in pytest output — a secret exposure risk
  • Added an autouse fixture using the existing _clear_keys() helper, matching the isolation pattern already used by TestResolveAgentEnvGemini in the same file

Test plan

  • All 7 tests in test_agent_env_resolution.py pass (including the previously failing test_gemini_only_mirrors_to_google)
  • Verified the fix works with real GEMINI_API_KEY / GOOGLE_API_KEY exported in the environment
  • ruff clean

Closes #522

🤖 Generated with Claude Code


Open in Devin Review

Tests called auto_inherit_env() without clearing os.environ, so real
API keys on the host would be inherited into the test env dict, causing
assertion failures that leak the key value into pytest output.

Add an autouse fixture using the existing _clear_keys() helper, matching
the isolation pattern already used by TestResolveAgentEnvGemini.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

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.

test_google_only_mirrors_to_gemini leaks GEMINI_API_KEY in assertion output and breaks §15 regression flow

1 participant