From 3e5aabc5f2b445f3e82d0f350ba52eb1f782b3e6 Mon Sep 17 00:00:00 2001 From: Mark Backman Date: Thu, 30 Apr 2026 09:33:33 -0400 Subject: [PATCH] fix(cartesia): guard HTTP session before use Pyright flagged the .post() call on a possibly-None _session. Raise a clear RuntimeError if start() wasn't called instead of crashing on the attribute access. --- pyrightconfig.json | 1 - src/pipecat/services/cartesia/tts.py | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pyrightconfig.json b/pyrightconfig.json index 5483be730..8f6b951c6 100644 --- a/pyrightconfig.json +++ b/pyrightconfig.json @@ -42,7 +42,6 @@ "src/pipecat/services/azure/stt.py", "src/pipecat/services/azure/tts.py", "src/pipecat/services/cartesia/stt.py", - "src/pipecat/services/cartesia/tts.py", "src/pipecat/services/deepgram/flux/base.py", "src/pipecat/services/deepgram/flux/sagemaker/stt.py", "src/pipecat/services/deepgram/flux/stt.py", diff --git a/src/pipecat/services/cartesia/tts.py b/src/pipecat/services/cartesia/tts.py index 192d5dc90..f91fa90b5 100644 --- a/src/pipecat/services/cartesia/tts.py +++ b/src/pipecat/services/cartesia/tts.py @@ -916,6 +916,9 @@ class CartesiaHttpTTSService(TTSService): logger.debug(f"{self}: Generating TTS [{text}]") try: + if self._session is None: + raise RuntimeError("HTTP session is not initialized; call start() before run_tts()") + voice_config = {"mode": "id", "id": self._settings.voice} output_format = {