Fixing SessionMessageHandler to handle multiple session tokens.#5521
Merged
v-isyamauchi-gh merged 1 commit intomainfrom Apr 27, 2026
Merged
Fixing SessionMessageHandler to handle multiple session tokens.#5521v-isyamauchi-gh merged 1 commit intomainfrom
v-isyamauchi-gh merged 1 commit intomainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5521 +/- ##
=======================================
Coverage ? 77.02%
=======================================
Files ? 982
Lines ? 35813
Branches ? 5396
=======================================
Hits ? 27585
Misses ? 6905
Partials ? 1323 🚀 New features to boost your workflow:
|
mikaelweave
approved these changes
Apr 24, 2026
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.
Description
We noticed that some tests recently started failing in AKS - FHIR Prod E2E test pipeline with an error, "InvalidOperationException: Sequence contains more than one element" in SessionMessageHandler.
SessionMessageHandler code incorrectly assumes a "x-ms-session-token" response header contains only one session token. (Note: Session tokens are partition-bound and the response may contain multiple session tokens when a request spans multiple partitions according to the source below. Also, we recently increased RU for the Gen1 test services to 20k.)
The change will update SessionMessageHandler to be able to handle multiple session tokens in the response.
Source:
https://learn.microsoft.com/en-us/azure/cosmos-db/how-to-manage-consistency?tabs=portal%2Cdotnetv2%2Capi-async#utilize-session-tokens
https://learn.microsoft.com/en-us/azure/cosmos-db/partitioning#physical-partitions
https://stackoverflow.com/questions/79335139/passing-session-token-for-querying-multiple-items-in-cosmosdb
Related issues
Addresses [issue #189767].
Bug 189767: FHIR PaaS Gen1: More than one "x-ms-session-token" are added in the response headers.
Testing
Tested by running existing tests (though best to test with running AKS - FHIR Prod E2E test pipeline)
FHIR Team Checklist
Semver Change (docs)
Patch|Skip|Feature|Breaking (reason)