Skip to content

Commit c4f5944

Browse files
Copilotfriggeri
andcommitted
Add graceful error handling for unknown/malformed session events in Python SDK
Co-authored-by: friggeri <106686+friggeri@users.noreply.github.com>
1 parent 014f926 commit c4f5944

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

python/copilot/client.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,11 @@ def handle_notification(method: str, params: dict):
726726
session_id = params["sessionId"]
727727
event_dict = params["event"]
728728
# Convert dict to SessionEvent object
729-
event = session_event_from_dict(event_dict)
729+
try:
730+
event = session_event_from_dict(event_dict)
731+
except Exception:
732+
# Silently ignore unknown/malformed event types for forward compatibility
733+
return
730734
with self._sessions_lock:
731735
session = self._sessions.get(session_id)
732736
if session:
@@ -801,7 +805,11 @@ def handle_notification(method: str, params: dict):
801805
session_id = params["sessionId"]
802806
event_dict = params["event"]
803807
# Convert dict to SessionEvent object
804-
event = session_event_from_dict(event_dict)
808+
try:
809+
event = session_event_from_dict(event_dict)
810+
except Exception:
811+
# Silently ignore unknown/malformed event types for forward compatibility
812+
return
805813
session = self._sessions.get(session_id)
806814
if session:
807815
session._dispatch_event(event)

0 commit comments

Comments
 (0)