langgenius/dify · critical · InternalServerError
Internal Server Error
Error message
Internal Server Error
What it means
HTTP 500 InternalServerError (werkzeug.exceptions.InternalServerError), the catch-all at the bottom of the STT endpoint's try/except. Any exception not matched by the specific service-error handlers (and not a ValueError) is logged via logger.exception('internal server error.') and converted to a 500. This is intentionally generic: it masks unexpected faults from the client while preserving a full stack trace server-side.
Source
Thrown at api/controllers/console/explore/audio.py:94
except UnsupportedAudioTypeServiceError:
raise UnsupportedAudioTypeError()
except ProviderNotSupportSpeechToTextServiceError:
raise ProviderNotSupportSpeechToTextError()
except SpeechToTextDisabledServiceError:
raise SpeechToTextDisabledError()
except ProviderTokenNotInitError as ex:
raise ProviderNotInitializeError(ex.description)
except QuotaExceededError:
raise ProviderQuotaExceededError()
except ModelCurrentlyNotSupportError:
raise ProviderModelCurrentlyNotSupportError()
except InvokeError as e:
raise CompletionRequestError(e.description)
except ValueError as e:
raise e
except Exception as e:
logger.exception("internal server error.")
raise InternalServerError()
@console_ns.route(
"/installed-apps/<uuid:installed_app_id>/text-to-audio",
endpoint="installed_app_text",
)
class ChatTextApi(InstalledAppResource):
@console_ns.expect(console_ns.models[TextToAudioPayload.__name__])
@console_ns.response(200, "Success", console_ns.models[AudioBinaryResponse.__name__])
@model_validate(TextToAudioPayload)
def post(self, req_data: TextToAudioPayload, installed_app: InstalledApp):
app_model = installed_app.app_with_session(session=db.session())
if app_model is None:
raise AppUnavailableError()
try:
message_id = req_data.message_id
text = req_data.text
voice = req_data.voiceView on GitHub (pinned to ef8544b173)
Solutions
- Read the server log for the logger.exception trace at this line — it is the authoritative source of the real cause.
- Reproduce with the same payload and fix the underlying fault, then add a specific service-error mapping if it is a recurring class of failure.
- If transient (DB/network), retry the request once.
- Do not expose this to end users; surface a friendly message in the client and report the incident with the log trace.
Defensive patterns
Strategy: try-catch
Try / catch
try { await postAudio(file) }
catch (e) {
if (e.status === 500) { reportIncident(e.request_id); showFriendlyError() }
else throw e
} Prevention
- Always correlate client errors to a server-side request id and ship the logger.exception trace to ops.
- Add integration tests for new AudioService paths so unexpected exceptions get specific handlers.
- Alert on any 500 spike from this endpoint; it indicates an unhandled fault.
When it happens
Trigger: POST /console/explore/installed-apps/{id}/audio-to-text that fails for a reason outside the enumerated service errors: an unanticipated TypeError/KeyError in AudioService, a database session error, a serialization bug, an unhandled model runtime exception type, or an infrastructure fault.
Common situations: Bug in a new code path not yet mapped to a service error; DB connection dropped mid-request; partial deploy where a module attribute is missing; an upstream library bumped and raised a new exception type the handler does not catch.
Understand the failure class
- HTTP status errors: handling 4xx and 5xx responses — how to handle 4xx and 5xx responses properly.
Related errors
- unsupported_audio_type
- provider_not_support_speech_to_text
- speech_to_text_disabled
- provider_not_initialize
- provider_quota_exceeded
AI-assisted analysis of langgenius/dify@ef8544b173 (2026-08-12).
Data as JSON: /api/errors/ccdb24af4a6a697b.
Report an issue: GitHub.