fix(speak): correct TTS warning event field names to match API response#653
Merged
lukeocodes merged 2 commits intomainfrom Jan 29, 2026
Merged
fix(speak): correct TTS warning event field names to match API response#653lukeocodes merged 2 commits intomainfrom
lukeocodes merged 2 commits intomainfrom
Conversation
Changed SpeakV1WarningEvent field names from `code`/`description` to `warn_code`/`warn_msg` to match the actual field names returned by the Deepgram API. This fixes Pydantic validation errors that were causing TTS WebSocket connections to crash instead of calling the on_warning callback when receiving 429 rate limit warnings. Updated all related tests to use the correct field names. Fixes #617
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug in the TTS WebSocket warning event handling by updating the SpeakV1WarningEvent model field names to match the actual Deepgram API response format, preventing validation errors that previously caused crashes.
Changes:
- Updated
SpeakV1WarningEventmodel fields fromcode/descriptiontowarn_code/warn_msg - Updated all related unit tests to use the corrected field names
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/deepgram/extensions/types/sockets/speak_v1_warning_event.py | Updated field names in the warning event model to match API response |
| tests/unit/test_speak_v1_models.py | Updated all test cases to use the corrected field names |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/deepgram/extensions/types/sockets/speak_v1_warning_event.py
Outdated
Show resolved
Hide resolved
naomi-deepgram
previously approved these changes
Jan 29, 2026
- Change docstring from 'Error code' to 'Warning code' to accurately reflect warning events - Fix test scenarios to consistently use warn_msg/warn_code field names
naomi-deepgram
approved these changes
Jan 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #617
Changed
SpeakV1WarningEventfield names fromcode/descriptiontowarn_code/warn_msgto match the actual field names returned by the Deepgram API.Issue
When the Deepgram API returns a 429 rate limit warning, the response contains:
{ "type": "Warning", "warn_code": "EXCESSIVE_FLUSH", "warn_msg": "Rate limit exceeded for flushes. Please try again later." }However, the SDK's
SpeakV1WarningEventmodel was expectingcodeanddescriptionfields instead, causing a Pydantic validation error that crashed the TTS WebSocket connection instead of calling theon_warningcallback.Changes
Updated
SpeakV1WarningEventmodel:code: str→warn_code: strdescription: str→warn_msg: strUpdated all related tests to use the correct field names
Impact
on_warningcallback will be properly invoked for 429 rate limit warningsTest plan
test_speak_v1_models.pyto use new field names