fix(guard): support request-scoped guards #2735
All Vouch review confidence checks passed
Residual risk 0.14 = Change Risk (0.36) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.36 · 207 lines diff across 2 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.319
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #2735"
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?
A guard that is request-scoped, or that depends on a request-scoped provider, fails every request with a 500 error:
ThrottlerGuardonly setsthrottlersinonModuleInit(), and Nest does not call that hook on request-scoped instances.Issue Number: N/A
What is the new behavior?
canActivate()callsonModuleInit()when the instance is not initialized yet. Static guards still initialize once at startup. The limit works across requests, because the storage is a shared singleton.Does this PR introduce a breaking change?
Other information
The new e2e test runs on Express and Fastify and failed on both before the fix. Unit tests (52), e2e tests (36), build and lint pass.
A request-scoped guard initializes once per request. With an empty configuration, the existing "no throttlers" warning is therefore logged per request.