Skip to content

Voice-only Discord message crashes handler: bare return prefix in _enrich_message_with_transcription (too many values to unpack) #42709

Closed

Description

@thebrunomaya

Summary

Any voice-only message on Discord (audio attachment with no accompanying text) crashes the entire message handler. The agent never replies. Looks like an STT/OpenAI failure but it is a plain Python unpacking bug — independent of STT provider, auth, or quota.

Error

ERROR gateway.platforms.base: [Discord] Error handling message: too many values to unpack (expected 2)
Traceback (most recent call last):
  ...
  File "gateway/run.py", line 7378, in _prepare_inbound_message_text
    message_text, _successful_transcripts = await self._enrich_message_with_transcription(
ValueError: too many values to unpack (expected 2)

Root cause

_enrich_message_with_transcription is declared -> tuple[str, List[str]] and all four call sites unpack two values. But one return branch still returns a bare string — the leftover from when the function returned -> str.

In gateway/run.py, the success block (transcription produced):

_placeholder = "(The user sent a message with no text content)"
if user_text and user_text.strip() == _placeholder:
    return prefix                                            # <-- BUG: bare str
if user_text:
    return f"{prefix}\n\n{user_text}", successful_transcripts
return prefix, successful_transcripts

The failure block right above it handles the identical branch correctly (return prefix, []), so this is clearly a missed conversion. When user_text equals the Discord adapter's empty-content placeholder (i.e. a voice-only message) and transcription succeeded, return prefix returns a string; the caller does a, b = "<string>", which unpacks the string's characters and raises.

Reproduction

  1. Discord adapter, STT enabled and working.
  2. Send a voice note with no text caption to the bot.
  3. Handler crashes with the error above; no reply is sent. (A voice note with a text caption works, because it takes the if user_text: branch.)

Fix

One line — mirror the sibling returns:

             if user_text and user_text.strip() == _placeholder:
-                return prefix
+                return prefix, successful_transcripts

successful_transcripts is in scope and is exactly what the two following returns already use.

Environment

  • Version: 0.16.0 (HEAD a77efada5)
  • Still present on origin/main (the bare return prefix is unchanged in the latest commit).
  • Platform: Discord adapter. Latent since the function was refactored from -> str to the 2-tuple return; only fatal once callers started unpacking.

Activity

  1. added
    type/bugSomething isn't working
    P2Medium — degraded but workaround exists
    comp/gatewayGateway runner, session dispatch, delivery
    tool/ttsText-to-speech and transcription
    on Jun 9, 2026
  2. liuhao1024 commented on Jun 9, 2026

    @liuhao1024

    This is fixed by #42710 — returns (prefix, successful_transcripts) from the voice-only transcription placeholder branch instead of a bare string.

  3. kshitijk4poor commented on Jun 10, 2026

    @kshitijk4poor

    Fixed by #42090 (merged in 9ca9697). The bare return prefix in the placeholder branch of _enrich_message_with_transcription now returns the (prefix, successful_transcripts) tuple, with a regression test covering the captionless-voice-note path. Thanks for the precise root-cause diagnosis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existscomp/gatewayGateway runner, session dispatch, deliveryplatform/discordDiscord bot adaptertool/ttsText-to-speech and transcriptiontype/bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions