microsoft / BotFramework-DirectLineJS

JavaScript client library for Microsoft Bot Framework's Direct Line protocol
MIT License
194 stars 127 forks source link

Support for bot error HTTP status code #44

Open dandriscoll opened 7 years ago

dandriscoll commented 7 years ago

Direct Line now returns an httpStatusCode field in the error JSON accompanying HTTP 502s caused by bot timeouts/errors. Is it possible to wire this up so clients have an easy time seeing the bot's HTTP status code?

Example below illustrates a bot returning HTTP 404.


HTTP/1.1 502
...

{
  "error": {
    "code": "ServiceError",
    "message": "Failed to send activity: bot returned an error"
  },
  "httpStatusCode": 404
}
billba commented 7 years ago

Ooooh! Pretty! I'll look into this.

rafaelmaeuer commented 5 years ago

I have the same strange error on a server environment, it's not happening on localhost. I thought it was related to an update of botbuilder from 3.13.1 to 3.15.0, but reverting the version didn't solve it. I can go to an earlier commit where it is still working, so what could possibly be the reason?

rafaelmaeuer commented 5 years ago

Solved it, the update of restify from version 6 to 7 caused this error on the server. Reverting fixed it.

watadarkstar commented 5 years ago

I might work on wiring this up. Not sure how difficult it will be... but it would be really useful for us to have these HTTP status codes available at the client level. It would save us some time debugging issues if we had access to the status code.

I've also been thinking... Could we get rid of the "retry" id and handle it as an error? Would be really nice to have that retry just be an error with status codes included. Sometimes that retry id is super ambiguous to us and we don't know what's going on. Same goes for not having http status codes from the bot propagate up to the client.

billba commented 5 years ago

I'm open to a better idea. I deeply regret the "retry" id -- one of those short term hacks that never got corrected.

watadarkstar commented 5 years ago

I'll try my best! 💪 I still don't fully understand what the retry id is telling me half the time, but I'll propose a PR with what I think would be a better solution.

compulim commented 5 years ago

For instance, Web Chat v4 no longer use activity ID of retry.

I think there are two parts here,

  1. Surface the HTTP error if we receive 502 from Direct Line platform
  2. Remove returning retry as activity ID and always throw an appropriate error (including 502 bot errors)
watadarkstar commented 5 years ago

In our app we have a fork that has something like this to get better error information: https://github.com/Microsoft/BotFramework-DirectLineJS/pull/115