Skip to content

[rush] Add experiment to trim RUSH_ env vars forwarded to operation processes - #5994

Open
Ian Clanton-Thuon (iclanton) with Copilot wants to merge 3 commits into
mainfrom
copilot/trim-rush-env-vars
Open

[rush] Add experiment to trim RUSH_ env vars forwarded to operation processes#5994
Ian Clanton-Thuon (iclanton) with Copilot wants to merge 3 commits into
mainfrom
copilot/trim-rush-env-vars

Conversation

Copilot AI commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Rush forwards nearly its entire process environment to operation processes (build/test scripts), including internal RUSH_-prefixed variables that operation scripts have no business depending on. This adds an opt-in experiment to exclude them.

Experiment flag

  • New trimRushEnvironmentVariablesForOperations boolean added to IExperimentsJson and experiments.schema.json. Disabled by default; no behavior change unless a repo opts in via experiments.json.

Filtering plugin

  • New TrimRushEnvironmentVariablesPlugin taps the existing createEnvironmentForOperation waterfall hook (same extension point as IgnoredParametersPlugin/NodeDiagnosticDirPlugin) and deletes any env var whose name starts with RUSH_ (case-insensitive), e.g.:
// experiments.json
{
  "trimRushEnvironmentVariablesForOperations": true
}
  • RUSHSTACK_* and other non-RUSH_ variables are left untouched.

Wiring

  • PhasedScriptAction registers the plugin before other env-forwarding plugins only when the experiment is enabled, scoping the trim strictly to operation processes (build/test/etc.), not rushx, event hooks, or custom global commands.

Docs/API

  • Updated common/reviews/api/rush-lib.api.md for the new public IExperimentsJson member and added a changelog entry for @microsoft/rush-lib.

Co-authored-by: iclanton <5010588+iclanton@users.noreply.github.com>
Comment thread libraries/rush-lib/src/logic/operations/TrimRushEnvironmentVariablesPlugin.ts Outdated
Comment thread libraries/rush-lib/src/logic/operations/TrimRushEnvironmentVariablesPlugin.ts Outdated
Comment thread libraries/rush-lib/src/schemas/experiments.schema.json
@iclanton

Copy link
Copy Markdown
Member

Copilot - take a look at the comments.

Co-authored-by: iclanton <5010588+iclanton@users.noreply.github.com>
@iclanton

Copy link
Copy Markdown
Member

Copilot - Can you investigate the build failure?

…g-convention rule

Co-authored-by: iclanton <5010588+iclanton@users.noreply.github.com>

Copilot AI commented Aug 28, 2026

Copy link
Copy Markdown
Contributor Author

Copilot - Can you investigate the build failure?

All 6 CI jobs failed for the same reason: rush retest --production treats build warnings as errors, and the new test file had an ESLint @typescript-eslint/naming-convention warning on the mock property Rush_Some_Mixed_Case_Var (mixed-case identifiers aren't allowed unless they match specific exemption patterns). Renamed it to rush_someMixedCaseVar in d13a973, which still exercises the case-insensitive RUSH_ prefix matching but satisfies the naming rule.

@iclanton Ian Clanton-Thuon (iclanton) changed the title Add experiment to trim RUSH_ env vars forwarded to operation processes [rush] Add experiment to trim RUSH_ env vars forwarded to operation processes Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs triage

Development

Successfully merging this pull request may close these issues.

2 participants