fix(config): keep expanded env files of every forRoot call for set() #2505
All Vouch review confidence checks passed
Residual risk 0.27 = Change Risk (0.63) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.63 · 296 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.341
Shallow Review Depth
shallow_review_depth
0.289
Sensitive Paths
sensitive_paths
0.063
Real PR Conversation Timeline
1 comments
"Review active on #2505"
general
weight: 0.35
kamilmysliwiec
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Since #2463,
ConfigService#set()re-expands env file variables that reference the key being set (for exampleURL=http://${HOST}/apifollowsset('HOST', ...)). The factory of eachforRoot()call hands its env file definitions to the sharedConfigService, and every call replaces them.So when an app calls
ConfigModule.forRoot()more than once (for example an app-level call plus a feature module with its own env file), the module that resolves last wins. If that call has noexpandVariables, the expanding call's definitions are dropped:With the imports in the other order it works, so the result depends on module order.
Issue Number: N/A
What is the new behavior?
Each
forRoot()call adds its definitions instead of replacing the others. They are merged in call order. When several env files define the same variable, the first call's definition is kept; this is the one loaded intoprocess.env, becauseforRootdoes not overwrite variables that are already set.Test:
tests/e2e/update-env-expanded.spec.tscovers both import orders. The "after" case fails on master (Received: "http://localhost/api"). Full suite: 145 tests pass.Does this PR introduce a breaking change?
Other information
setExpansionEnv/setPredefinedEnvare still set per call. I left them as they are to keep this change small.