You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
.NET: [Bug]: CosmosChatMessageStore methods GetMessageCountAsync and ClearMessagesAsync always return 0 due to case-sensitivity in query #3460
What happened?
When using CosmosChatMessageStore, calls to GetMessageCountAsync() and ClearMessagesAsync() always return 0, even when there are messages present in the container that can be retrieved via other methods.
What did you expect to happen?
GetMessageCountAsync() should return the actual number of messages for the given conversation, and ClearMessagesAsync() should delete the messages and return the count of removed items.
Steps to reproduce the issue:
Initialize CosmosChatMessageStore with a valid connection string and container.
Add messages to the store (or verify they exist).
Call GetMessageCountAsync().
Observe that it returns 0 regardless of the actual data.
Code Sample
var cosmosProvider = new CosmosChatMessageStore(
"AccountEndpoint=xxxx;AccountKey=xxxx",
"my-databaseid",
"my-container",
"my-conversationId");
// Retrieval works fine
var messages = await cosmosProvider.InvokingAsync(new ChatMessageStore.InvokingContext([]));
// Bug: Always returns 0
var count = await cosmosProvider.GetMessageCountAsync();
// Bug: No messages are deleted and returns 0
var removedMessagesCount1 = await cosmosProvider.ClearMessagesAsync();
Error Messages / Stack Traces
No exception is thrown; the methods silently fail to match any documents due to an incorrect property name in the underlying Cosmos DB SQL query.
The issue appears to be caused by a case-sensitivity mismatch in the query string.
In CosmosChatMessageStore.cs, the query uses c.Type = @type instead of c.type = @type (lowercase 't').
Activity