Skip to content

.NET: Fix case-sensitivity bug in Cosmos DB queries for GetMessageCountAsyn…#4139

Closed
alliscode wants to merge 4 commits intomicrosoft:mainfrom
alliscode:fix/cosmos-query-case-sensitivity
Closed

.NET: Fix case-sensitivity bug in Cosmos DB queries for GetMessageCountAsyn…#4139
alliscode wants to merge 4 commits intomicrosoft:mainfrom
alliscode:fix/cosmos-query-case-sensitivity

Conversation

@alliscode
Copy link
Member

This pull request makes a minor update to the CosmosChatHistoryProvider class to ensure consistency in querying the Cosmos DB. The change standardizes the casing for the type property in query definitions.

  • Updated query definitions in GetMessageCountAsync and ClearMessagesAsync methods to use c.type instead of c.Type for consistency with the database schema. [1] [2]

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

…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>
Copilot AI review requested due to automatic review settings February 20, 2026 19:53
@github-actions github-actions bot changed the title Fix case-sensitivity bug in Cosmos DB queries for GetMessageCountAsyn… .NET: Fix case-sensitivity bug in Cosmos DB queries for GetMessageCountAsyn… Feb 20, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 GetMessageCountAsync query to use lowercase c.type instead of c.Type for correct JSON property matching
  • Fixed ClearMessagesAsync query to use lowercase c.type instead of c.Type for 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>
@alliscode alliscode added this pull request to the merge queue Feb 23, 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>
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 23, 2026
@alliscode alliscode added this pull request to the merge queue Feb 23, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 23, 2026
alliscode and others added 2 commits February 23, 2026 11:25
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>
@alliscode alliscode closed this Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants