fix(core): merge request context with tenant context payload in the request singleton #13485
+73
−7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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?
Doesn't create the request singleton with the contextId payload when the first request isn't to a durable tree.
Issue Number: #13477
What is the new behavior?
The payload generated by the contextIdFactory will be always merged to the request singleton, not matter if the the tree is durable or not.
Does this PR introduce a breaking change?
Other information
I would like to know which tests should I updated, if needed.
Also the patch doesn't merge payload from the contextIdFactory in the request passed to canActivate method for AuthGuard and exception filter.
To patch the case above:
packages/core/router/router-explorer.ts
lines 389 and 402..., instanceWrapper.id, )(req, res, next);
should be replace by
..., instanceWrapper.id, )(Object.assign(req, contextId.payload), res, next);
and
const host = new ExecutionContextHost([req, res, next]);
should be replace by
const host = new ExecutionContextHost([Object.assign(req, contextId.payload), res, next]);
But I don't want to do it on my own since I would like a quick fix first, moreover maybe it will imply edge-case, I don't know the code base well 🤷♂️