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 <noreply@anthropic.com>
This commit is contained in:
James Hush
2026-02-03 16:26:09 +08:00
parent a627597bca
commit b030f1178d
2 changed files with 7 additions and 0 deletions

1
changelog/3629.fixed.md Normal file
View File

@@ -0,0 +1 @@
- Fixed `StopAsyncIteration` exceptions in `parse_telephony_websocket()` when WebSocket connections close before sending expected messages.

View File

@@ -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)