0

I've recently deployed a bot for many users. Sometimes when I call EndDialogAsync() I get a BadRequest error.

Here's my stack trace:

Microsoft.Bot.Schema.ErrorResponseException

Operation returned an invalid status code 'BadRequest'

Bot.CustomPrompts.CustomPrompt in OnPromptAsync at line 37:17 within BasicBot, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null

Called from: System.Runtime.ExceptionServices.ExceptionDispatchInfo in Throw within System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
 Bot.Dialogs.Tour.TourDialog+<>c__DisplayClass0_0+<<-ctor>b__10>d in MoveNext at line 512:17 within BasicBot, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
Called from: System.Runtime.ExceptionServices.ExceptionDispatchInfo in Throw within System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e

Line 512 of TourDialog is: return await stepContext.EndDialogAsync();

And Line 37 of CustomPrompt is: await turnContext.SendActivityAsync(options.Prompt, cancellationToken).ConfigureAwait(false);

It seems like the dialog is being ended and so the stepContext should no longer exists. CustomPrompt is a custom class for realizing AdaptivePrompts within botframework v4 (found here Adaptive Card response from a WaterfallStep Dialog MS Bot framework v4). I don't know why CustomPrompt is being called at all because the dialog should have ended.

craigbot
  • 345
  • 1
  • 2
  • 15
  • Can we see your CustomPrompt class? I'm guessing you're calling `EndDialogAsync` from a waterfall step. Can we see your waterfall as well? – Kyle Delaney Apr 04 '19 at 20:44
  • Here is CustomPrompt: https://gist.github.com/MilesWilde/fd595f3031ba0c303dd9eb506061433 Is it ok if I give a snippet of the waterfall for NDA reasons? https://gist.github.com/MilesWilde/8f44a650da3620eedece9f1d90a643fa Line 512 becomes Line 71 in my gist. I could link you the whole waterfall in a private message potentially if the whole thing is required. – craigbot Apr 04 '19 at 21:02
  • I still don't have enough of your code to figure out what's going on, but if you want to share your bot with me over email then I could probably figure it out. You have to remember that `EndDialogAsync` will pop just one dialog off the stack, and so if there are any other dialogs still on the stack then the one on top will become the new active dialog and its `ResumeDialogAsync` will be called, which can potentially send messages. – Kyle Delaney Apr 10 '19 at 23:08
  • Sorry other things are taking precedence at the moment - will get back to you on this – craigbot Apr 23 '19 at 20:20
  • Are you still going to get back to me? – Kyle Delaney May 14 '19 at 21:21
  • Hey Kyle, sorry for the long response - is it still possible to send you the bot over e-mail? – craigbot May 22 '19 at 15:34
  • Yes of course, my email is on my profile – Kyle Delaney May 29 '19 at 21:04

1 Answers1

1

You have to remember that EndDialogAsync will pop just one dialog off the stack, and so if there are any other dialogs still on the stack then the one on top will become the new active dialog and its ResumeDialogAsync will be called, which can potentially send messages.

Kyle Delaney
  • 11,616
  • 6
  • 39
  • 66