.NET: Fix case-sensitivity bug in Cosmos DB queries for GetMessageCountAsyn…#4139
Closed
alliscode wants to merge 4 commits intomicrosoft:mainfrom
Closed
.NET: Fix case-sensitivity bug in Cosmos DB queries for GetMessageCountAsyn…#4139alliscode wants to merge 4 commits intomicrosoft:mainfrom
alliscode wants to merge 4 commits intomicrosoft:mainfrom
Conversation
…c and ClearMessagesAsync The count and delete queries used c.Type (capital T) instead of c.type (lowercase t), which doesn't match the stored document property name. Cosmos DB property names are case-sensitive, so these queries would always return 0 results. Fixes the same issue as microsoft#3485 but applied cleanly to current main. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request fixes a critical case-sensitivity bug in Cosmos DB queries within the CosmosChatHistoryProvider class. The issue stems from a mismatch between C# property names (PascalCase) and JSON property names (camelCase) as defined by Newtonsoft.Json attributes.
Changes:
- Fixed
GetMessageCountAsyncquery to use lowercasec.typeinstead ofc.Typefor correct JSON property matching - Fixed
ClearMessagesAsyncquery to use lowercasec.typeinstead ofc.Typefor correct JSON property matching
Verifies that the count and clear queries correctly match stored documents by using the proper lowercase 'type' property name in Cosmos DB queries. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
peibekwe
approved these changes
Feb 20, 2026
TaoChenOSU
approved these changes
Feb 20, 2026
crickman
approved these changes
Feb 21, 2026
github-merge-queue bot
pushed a commit
that referenced
this pull request
Feb 23, 2026
…ntAsyn… (#4139) * Fix case-sensitivity bug in Cosmos DB queries for GetMessageCountAsync and ClearMessagesAsync The count and delete queries used c.Type (capital T) instead of c.type (lowercase t), which doesn't match the stored document property name. Cosmos DB property names are case-sensitive, so these queries would always return 0 results. Fixes the same issue as #3485 but applied cleanly to current main. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add tests for GetMessageCountAsync and ClearMessagesAsync Verifies that the count and clear queries correctly match stored documents by using the proper lowercase 'type' property name in Cosmos DB queries. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: alliscode <bentho@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The PR's test methods (GetMessageCountAsync and ClearMessagesAsync tests) were duplicated by equivalent tests that were independently added to main. Remove the PR's copies to resolve CS0111 compilation errors, keeping the more thorough versions from main. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
This pull request makes a minor update to the
CosmosChatHistoryProviderclass to ensure consistency in querying the Cosmos DB. The change standardizes the casing for thetypeproperty in query definitions.GetMessageCountAsyncandClearMessagesAsyncmethods to usec.typeinstead ofc.Typefor consistency with the database schema. [1] [2]Contribution Checklist