Backport to 5.2 — Fix per-request composer leaked into cached endpoint pipeline (#1040)#1042
Merged
Conversation
Member
mauroservienti
commented
May 12, 2026
- Backport of Per-request composer leaked into cached endpoint pipeline #1040
CompositionEndpointBuilder.Build() builds a fresh `composer` lambda per request that closes over that request's `argumentsByComponent`. The first request also builds the endpoint filter pipeline which closes over that first composer; subsequent requests find `cachedPipeline` non-null and reuse it, so they re-run the first request's composer with the first request's bound arguments. Symptom: every contract-less handler observed the first request's route values and body. e.g. `GET /existingCart/aaaa` then `GET /existingCart/bbbb` both saw `orderId == aaaa`; POSTing different quantities all stored the first quantity. Fix: stash the per-request composer in `HttpContext.Items` and read it back from there inside the cached pipeline's innermost delegate. The pipeline itself stays cached and structural; only the composer varies per request. Adds Per_request_arguments_are_not_shared as a regression test: fires two sequential GETs against an `int id` route and asserts both responses echo their own id.
1474e60 to
6dbd7a6
Compare
1474e60 to
6dbd7a6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.