You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: handle malformed JSON in WebSocket handler gracefully (fixes#257) (#259)
* fix: handle malformed JSON in WebSocket handler gracefully
Wrap json.loads() in chatbot_stream with a try/except for
json.JSONDecodeError. On malformed input, the handler now:
1. Logs a warning with the session ID
2. Sends a JSON error back: {"error": "Invalid JSON format."}
3. Continues listening for the next message
Previously, a single malformed message would propagate to the
outer except Exception block, terminating the entire WebSocket
connection.
Fixes#257
* test: add WebSocket unit tests for malformed JSON handling
---------
Co-authored-by: Bervianto Leo Pratama <[email protected]>
0 commit comments