Bot state not preserved for Dialog
Bot Info
- SDK Platform: NET
- SDK Version: 3.15
- Active Channels: Web, Direct Line, Emulator
- Deployment Environment: Azure Bot Service, local development with Emulator
Issue Description
A previously working (for some considerable time) bot is no longer restored back from state.
We have a number of public properties on the bot which we use to record user responses, as well as state flags and cached results.
Some changes including an additional serialisable object has been added as a property and the bot functions but state is no longer preserved. Object properties are now null, Booleans default to false, etc.
I can see using the Azure Storage Explorer that entries are being written to the botdata table while the bot is in use.
I've made sure all the classes referenced by public properties are serialisable, and followed those through to any child objects they refer to ensuring they are serialisable as well.
My current suspicion is that the bot can serialise to Azure storage, but perhaps can't deserialise back again, but the absence of errors or diagnostic logging in Azure storage means that just a guess.
I'm continuing to focus on any public properties and objects referenced as public properties, but appear to have exhausted that line of investigation.
Is there a way of getting some errors or logging back from the state management service to provide more insight into what's gone wrong?
Can you share your dialog code?
Also, have you tried sending '/deleteProfile' to the bot for the users who are having issues? reference: https://docs.microsoft.com/en-us/azure/bot-service/bot-service-troubleshoot-general-problems?view=azure-bot-service-3.0#how-do-i-version-the-bot-data-stored-through-the-state-api
It's a substantial lump of code now, so I can't share it with the world. I'm hoping there's a way of getting some kind of diagnostic information from the state management system - a silent failure to serialise/deserialise isn't giving me any clues to work with at the moment.
All users are affected, all new installations of code are also affected.
Finally getting somewhere and found an error, this thread appears to be similar: https://github.com/Microsoft/BotBuilder/issues/3811
@MarkHirst Have you implemented a custom state service using the Bot Builder Azure Extensions? https://github.com/Microsoft/BotBuilder-Azure
I'm using Azure Table storage following this article: https://docs.microsoft.com/en-us/azure/bot-service/dotnet/bot-builder-dotnet-state-azure-table-storage?view=azure-bot-service-3.0
That code didn't change between the version of our bot that worked, and the one that doesn't. I'm comparing the properties of the two versions to see what might be causing serialisation problems.
I thought of trying the binary formatter to serialise both versions, but it turns out neither can be serialised using it, so I can't use that as a way of determining what makes the newer version fail.
After a lot of digging, I finally found a reference to a Bot Framework class added in a recent change, and that class was not serializable.