Skip to content

πŸ› [Streaming Chat] Improve error handling on bad chat request messagesΒ #272

Open
@roma-glushko

Description

@roma-glushko

A Glide's streaming channel gets closed on chat requests that doesn't pass validation.
The issue is in the way we handle errors right now:

if err = c.ReadJSON(&chatRequest); err != nil {
// TODO: handle bad request schemas gracefully and return back validation errors
if websocket.IsUnexpectedCloseError(err, websocket.CloseNormalClosure, websocket.CloseGoingAway) {
tel.L().Warn("Streaming Chat connection is closed", zap.Error(err), zap.String("routerID", routerID))
}
tel.L().Debug("Streaming chat connection is closed by client", zap.Error(err), zap.String("routerID", routerID))
break
}

For example, you can open a streaming chat connection (via Postman, for example):

{{base_url}}/language/{{routerID}}/chatStream

Then, send it just an empty message like:

{
  
}

You would get an error like:
Screenshot 2024-06-13 at 22 40 16

Finally, if you try to send a valid message now:

"message": {
    "role": "user",
    "content": "Write an essay about ecommerce in a modern era"
  }

It would not really work.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions