diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d0060f..1b90e78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [5.0.0-patch-1] - 2026-03-16 + +- Gracefully handle unknown message types + ## [5.0.0] - 2025-08-14 - Moved channel field to root of AddTranscript message for multichannel transcription. diff --git a/VERSION b/VERSION index 0062ac9..9e7470c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5.0.0 +5.0.0-patch-1 diff --git a/speechmatics/client.py b/speechmatics/client.py index f2ce193..4ce18f8 100644 --- a/speechmatics/client.py +++ b/speechmatics/client.py @@ -255,12 +255,15 @@ def _consumer(self, message): message = json.loads(message) message_type = message["message"] - for handler in self.event_handlers[message_type]: - try: - handler(copy.deepcopy(message)) - except ForceEndSession: - LOGGER.warning("Session was ended forcefully by an event handler") - raise + try: + for handler in self.event_handlers[message_type]: + try: + handler(copy.deepcopy(message)) + except ForceEndSession: + LOGGER.warning("Session was ended forcefully by an event handler") + raise + except KeyError as kex: + LOGGER.debug(f"Unknown handler for message type: {message_type} {kex=}") if message_type == ServerMessageType.RecognitionStarted: self._flag_recognition_started()