botframework-sdk: [C#] Exception in PersistBotData when use custom IBotToUser implementation
I want to use my custom IBotToUser
implementation. While the SendLastInline_BotToUser
is sealed, I wraped it and registered my implementation like it done in the DirectConversation. That working perfectly in the Bot Emulator, but when deployed it started throwing of exception:
Microsoft.Rest.HttpOperationException: The remote server returned an error: (400) Bad Request.
at Microsoft.Bot.Connector.ErrorHandling.HandleError[ObjectT](HttpOperationResponse`1 result)
at Microsoft.Bot.Connector.BotsExtensions.<SetConversationDataAsync>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Bot.Builder.Dialogs.Internals.PersistentDialogTask.<PersistBotData>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Bot.Builder.Dialogs.Internals.PersistentDialogTask.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d__5`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MyBot.MessagesController.<SendAsync>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MyBot.MessagesController.<Post>d__2.MoveNext()
Looking at the PersistentDialogTask I found checking of the type. When I changed the check to take my implementation into account, the exception is gone.
So, I see two possible solutions:
- Unseal the
SendLastInline_BotToUser
to make the type check working for derived classes. - Introduce some property in the
IBotToUser
(or in a new derived interface) to understand if thePersistBotData
call should be done. Additionally, I’m not sure what will happen on unconditional call ofPersistBotData
in the catch. Let me know if I can make a PR with one of the suggested fixes. Or maybe I’m doing this wrong and there is a better way to use customIBotToUser
implementation?
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 15 (14 by maintainers)
It seems that there is a bug in the way that we set the etag. Try
var etag = "*";
and it should fix it for you.