-
Notifications
You must be signed in to change notification settings - Fork 479
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cosmos DB Throws "Unable to cast object of type 'System.Int64' to type 'System.Int32'" when Calling ContinueDialogAsync #1859
Comments
@NiteLordz - Can you provide the code for the dialog you're running? |
@NiteLordz, can you provide the full Exception stack? I would love to see the stack trace. Also, if you can provide code that replicates the issue, we can quickly track it down. |
Stack Trace: TestCosmosBot.TestCosmosBotBot:Error: Exception caught : System.InvalidCastException: Unable to cast object of type 'System.Int64' to type 'System.Int32'.
at Microsoft.Bot.Builder.Dialogs.Prompt`1.ContinueDialogAsync(DialogContext dc, CancellationToken cancellationToken)
at Microsoft.Bot.Builder.Dialogs.DialogContext.ContinueDialogAsync(CancellationToken cancellationToken) in d:\a\1\s\libraries\Microsoft.Bot.Builder.Dialogs\DialogContext.cs:line 160
at Microsoft.Bot.Builder.Dialogs.ComponentDialog.ContinueDialogAsync(DialogContext outerDc, CancellationToken cancellationToken) in d:\a\1\s\libraries\Microsoft.Bot.Builder.Dialogs\ComponentDialog.cs:line 86
at Microsoft.Bot.Builder.Dialogs.DialogContext.ContinueDialogAsync(CancellationToken cancellationToken) in d:\a\1\s\libraries\Microsoft.Bot.Builder.Dialogs\DialogContext.cs:line 160
at TestCosmosBot.TestCosmosBotBot.OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken) in C:\Users\v-eridah\source\repos\TestCosmosBot\TestCosmosBot\TestCosmosBotBot.cs:line 125
at Microsoft.Bot.Builder.BotFrameworkAdapter.TenantIdWorkaroundForTeamsMiddleware.OnTurnAsync(ITurnContext turnContext, NextDelegate next, CancellationToken cancellationToken) in d:\a\1\s\libraries\Microsoft.Bot.Builder\BotFrameworkAdapter.cs:line 964
at Microsoft.Bot.Builder.MiddlewareSet.ReceiveActivityWithStatusAsync(ITurnContext turnContext, BotCallbackHandler callback, CancellationToken cancellationToken) in d:\a\1\s\libraries\Microsoft.Bot.Builder\MiddlewareSet.cs:line 55
at Microsoft.Bot.Builder.BotAdapter.RunPipelineAsync(ITurnContext turnContext, BotCallbackHandler callback, CancellationToken cancellationToken) in d:\a\1\s\libraries\Microsoft.Bot.Builder\BotAdapter.cs:line 167 |
Perhaps it's this cast right here: https://github.com/Microsoft/botbuilder-dotnet/blob/4.4/libraries/Microsoft.Bot.Builder.Dialogs/Prompts/Prompt.cs#L90 Perhaps CosmosDB stores the counter as an Int64 by default and so that's how it gets read. |
That line was introduced very recently: https://github.com/Microsoft/botbuilder-dotnet/pull/1774/files#diff-1bbbc8f550395adfa5f014863009e56dR90 I presume the counter is being cast from an object to an integer so that arithmetic can be performed on it, but it wasn't considered what size of integer it should be. I wonder if there's some recommended way this kind of situation is meant to be handled. We could cast it as a |
|
we're cutting a 4.4.1 release of the C# SDK to address this issue. |
Just confirmed this is now working in 4.4.1 Great work! |
Thank you for reporting this @NiteLordz |
Github issues should be used for bugs and feature requests. Use Stack Overflow for general "how-to" questions.
Version
Microsoft.Bot.Builder v4.4.0
Describe the bug
When executing line
await dialogContext.ContinueDialogAsync(cancellationToken)
System.InvalidCastException is thrown with details "Unable to cast object of type 'System.Int64' to type 'System.Int32'"
To Reproduce
Steps to reproduce the behavior:
Using CosmosDB storage
Execute the first message, works fine
Upon the second message, calling ContinueDialogAsync(...) fails
Expected behavior
Give a clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
Using MemoryStorage does not have this problem
Works fine in version 4.3.0
[bug]
The text was updated successfully, but these errors were encountered: