Skip to content

never retrieved exception=WSServerHandshakeError leads to published Cartesia API Key in logs #6739

Closed

Description

@AdemFr

Bug Description

On agent worker failures we saw

Task exception was never retrieved
exception=WSServerHandshakeError(RequestInfo(url=URL('wss://api.cartesia.ai/tts/websocket?cartesia_version=2025-04-16'), method='GET', headers=<CIMultiDictProxy('Host': 'api.cartesia.ai', 'User-Agent': 'LiveKit Agents Cartesia Plugin/1.6.6', 'X-API-Key': '<RAW_API_KEY>', 'Upgrade': 'websocket', 'Connection': 'Upgrade', 'Sec-WebSocket-Version': '13', 'Sec...

Not sure if the cartesia plugin, or more generally the livekit agents package should handle this better.

Here is an AI diagnostic of the issue:

  1. LiveKit's ConnectionPool.prewarm() fires _prewarm_impl() as a task and keeps only a weakref — on failure nothing awaits it.
  2. The task is GC'd unretrieved, so CPython's asyncio handler logs it, repr()-ing the future.
  3. Task.repr embeds the exception's repr.
  4. aiohttp.ClientResponseError.repr interpolates its RequestInfo, which is a NamedTuple containing the outgoing request headers.
  5. The Cartesia plugin puts the key in those headers.

Expected Behavior

No API Key should ever make it into logs from any third party.

Reproduction Steps

1. 
2.
3.
...
- Sample code snippet, or a GitHub Gist link -

Operating System

Linux

Models Used

Cartesia Sonic 3.5

Package Versions

livekit==1.1.13
livekit-agents==1.6.6
livekit-api==1.2.0
livekit-blingfire==1.1.0
livekit-local-inference==0.2.6
livekit-plugins-cartesia==1.6.6
livekit-plugins-deepgram==1.6.6
livekit-plugins-elevenlabs==1.6.6
livekit-plugins-noise-cancellation==0.2.5
livekit-plugins-openai==1.6.6
livekit-protocol==1.1.19

Session/Room/Call IDs

No response

Proposed Solution

Additional Context

No response

Screenshots and Recordings

No response

Activity

  1. changed the title [-]never retrieved exception=WSServerHandshakeError leads to published API Key in logs[/-] [+]never retrieved exception=WSServerHandshakeError leads to published Cartesia API Key in logs[/+] on Aug 7, 2026
  2. self-assigned this
    on Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions