From b030f1178dc4b42e07e89276346a730c850f8a83 Mon Sep 17 00:00:00 2001 From: James Hush Date: Tue, 3 Feb 2026 16:26:09 +0800 Subject: [PATCH] Add changelog and improve docstring for parse_telephony_websocket - Added changelog entry for bug fix - Enhanced docstring with Args and Raises sections Co-Authored-By: Claude Sonnet 4.5 --- changelog/3629.fixed.md | 1 + src/pipecat/runner/utils.py | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 changelog/3629.fixed.md diff --git a/changelog/3629.fixed.md b/changelog/3629.fixed.md new file mode 100644 index 000000000..12792f47d --- /dev/null +++ b/changelog/3629.fixed.md @@ -0,0 +1 @@ +- Fixed `StopAsyncIteration` exceptions in `parse_telephony_websocket()` when WebSocket connections close before sending expected messages. diff --git a/src/pipecat/runner/utils.py b/src/pipecat/runner/utils.py index 2a56bb0f4..a3be74436 100644 --- a/src/pipecat/runner/utils.py +++ b/src/pipecat/runner/utils.py @@ -96,6 +96,9 @@ def _detect_transport_type_from_message(message_data: dict) -> str: async def parse_telephony_websocket(websocket: WebSocket): """Parse telephony WebSocket messages and return transport type and call data. + Args: + websocket: FastAPI WebSocket connection from telephony provider. + Returns: tuple: (transport_type: str, call_data: dict) @@ -136,6 +139,9 @@ async def parse_telephony_websocket(websocket: WebSocket): "to": str, } + Raises: + ValueError: If WebSocket closes before sending any messages. + Example usage:: transport_type, call_data = await parse_telephony_websocket(websocket)