Dashboardsentry-api-schemagetsentry/cli uses setEnv/getEnv for en…

getsentry/cli uses setEnv/getEnv for env isolation in tests

Category: pattern
Confidence: 0.90
ID: 019de1e9-ce08-7b44-bff2-3de8729e0f93
Project ID: 6c9a871d-74f1-447a-a3e8-d61a6564a1a1
Cross-project: No
Recalled in other projects: 0
Source session: (none)
Created: 2026-08-06 12:05:45
Updated: 2026-08-06 12:05:45

Content

The repo isolates environment variables via src/lib/env.tssetEnv(env) overrides the active env, getEnv() returns it. Tests that depend on env vars should call setEnv({ VAR: 'val' } as NodeJS.ProcessEnv) and restore with setEnv(process.env) in a try/finally. Detection functions like detectAgent() read from getEnv(), not process.env directly.

Move to: