Skip to content

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

Merged
Ian Clanton-Thuon (iclanton) merged 3 commits into
mainfrom
copilot/trim-rush-env-vars
Aug 31, 2026
Merged

[rush] Add experiment to trim RUSH_ env vars forwarded to operation processes#5994
Ian Clanton-Thuon (iclanton) merged 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
@iclanton
Ian Clanton-Thuon (iclanton) merged commit 055e384 into main Aug 31, 2026
10 checks passed
@iclanton
Ian Clanton-Thuon (iclanton) deleted the copilot/trim-rush-env-vars branch August 31, 2026 18:28
@github-project-automation github-project-automation Bot moved this from Needs triage to Closed in Bug Triage Aug 31, 2026
Jérémy Dieuze (QuanticPotatoes) added a commit to QuanticPotatoes/rushstack that referenced this pull request Sep 1, 2026
microsoft#5994 exported this regexp for TrimRushEnvironmentVariablesPlugin.
The GVS follow-up accidentally dropped it and inlined /^RUSH_/i.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Closed

Development

Successfully merging this pull request may close these issues.

3 participants