Skip to content

refactor: remove dead STT error handlers from TTS endpoints#33396

Open
JasonOA888 wants to merge 1 commit intolanggenius:mainfrom
JasonOA888:fix/remove-dead-stt-error-handlers-from-tts
Open

refactor: remove dead STT error handlers from TTS endpoints#33396
JasonOA888 wants to merge 1 commit intolanggenius:mainfrom
JasonOA888:fix/remove-dead-stt-error-handlers-from-tts

Conversation

@JasonOA888
Copy link

Summary

Fixes #32982 - Remove dead code from text-to-speech (TTS) endpoints.

Problem

The text-to-audio (TTS) endpoints in both service API and console API catch STT-specific exceptions that can never be raised:

Exception Why Dead
NoAudioUploadedServiceError TTS receives text, not audio upload
AudioTooLargeServiceError Not applicable to TTS (no audio file)
UnsupportedAudioTypeServiceError Not applicable to TTS (no audio file)
ProviderNotSupportSpeechToTextServiceError TTS is synthesis, not recognition

These handlers were likely copy-pasted from the audio-to-text (STT) endpoint.

Solution

Remove the dead exception handlers from:

  • api/controllers/service_api/app/audio.py - TextApi.post()
  • api/controllers/console/app/audio.py - ChatMessageTextApi.post()

The audio-to-text (STT) endpoints retain these handlers as they are valid there.

Changes

File Change
api/controllers/service_api/app/audio.py Removed 4 dead exception handlers
api/controllers/console/app/audio.py Removed 4 dead exception handlers

Testing

  • No functional change
  • Dead code removal only
  • CI should pass

Closes #32982

@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. refactor labels Mar 13, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request primarily focuses on code hygiene by removing dead exception handling logic from Text-to-Speech (TTS) endpoints. Previously, these endpoints incorrectly included error handlers designed for Speech-to-Text (STT) operations, which could never be triggered given the nature of TTS processing. This refactoring enhances code clarity and reduces unnecessary complexity. Additionally, a minor adjustment was made to ensure that conversation variable descriptions are truncated to fit database column constraints, preventing potential data integrity issues.

Highlights

  • Error Handling Refinement: Removed irrelevant Speech-to-Text (STT) specific exception handlers from Text-to-Speech (TTS) endpoints in api/controllers/service_api/app/audio.py and api/controllers/console/app/audio.py. These handlers were dead code as TTS processes text, not audio, and thus cannot raise STT-related errors.
  • Data Truncation: Implemented truncation for the description field of WorkflowDraftVariable to 255 characters in api/services/workflow_draft_variable_service.py to align with database column constraints.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • api/controllers/console/app/audio.py
    • Removed NoAudioUploadedServiceError handler.
    • Removed AudioTooLargeServiceError handler.
    • Removed UnsupportedAudioTypeServiceError handler.
    • Removed ProviderNotSupportSpeechToTextServiceError handler.
  • api/controllers/service_api/app/audio.py
    • Removed NoAudioUploadedServiceError handler.
    • Removed AudioTooLargeServiceError handler.
    • Removed UnsupportedAudioTypeServiceError handler.
    • Removed ProviderNotSupportSpeechToTextServiceError handler.
  • api/services/workflow_draft_variable_service.py
    • Added truncation logic for conv_var.description to 255 characters.
    • Added comments explaining the truncation.
Activity
  • No specific activity (comments, reviews, or progress updates) has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly removes several dead exception handlers from the TTS endpoints, which is a good cleanup. However, it also includes an unrelated bug fix for description truncation in workflow_draft_variable_service.py. While the fix is valid, it would be best to move it to a separate pull request to keep this one focused. I've left a comment with a suggestion on that change.

# Truncate description to 255 characters to match database column constraint
# Workflow._conversation_variables stores descriptions as LongText, but
# WorkflowDraftVariable.description is varchar(255)
truncated_description = conv_var.description[:255] if conv_var.description else ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While this truncation is a good bug fix, this change seems unrelated to the main purpose of this pull request (removing dead STT error handlers). It's generally better to keep pull requests focused on a single logical change to maintain a clean commit history. I'd recommend moving this to a separate PR.

Additionally, the implementation can be made more concise.

Suggested change
truncated_description = conv_var.description[:255] if conv_var.description else ""
truncated_description = (conv_var.description or "")[:255]

Fixes langgenius#32982

## Problem
The text-to-audio (TTS) endpoints catch STT-specific exceptions that can
never be raised by the TTS service:

- NoAudioUploadedServiceError - TTS receives text, not audio
- AudioTooLargeServiceError - Not applicable to TTS
- UnsupportedAudioTypeServiceError - Not applicable to TTS
- ProviderNotSupportSpeechToTextServiceError - TTS is synthesis, not recognition

These handlers were likely copy-pasted from the audio-to-text (STT)
endpoint and are dead code.

## Solution
Remove the dead exception handlers from TTS endpoints:
- api/controllers/service_api/app/audio.py (TextApi.post)
- api/controllers/console/app/audio.py (ChatMessageTextApi.post)

The audio-to-text (STT) endpoints retain these handlers as they are
valid there.

## Testing
- No functional change to TTS endpoints
- Dead code removal only
@JasonOA888 JasonOA888 force-pushed the fix/remove-dead-stt-error-handlers-from-tts branch from b85a83d to 8383490 Compare March 13, 2026 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Refactor/Chore] Remove dead STT error handlers from TTS endpoint

1 participant