From 6a338654fb0a7fe16527e087fce8d82192228d92 Mon Sep 17 00:00:00 2001 From: shakti Date: Tue, 21 Jul 2026 07:49:24 +0530 Subject: [PATCH] fix: return 400 instead of 500 when file field is missing in audio-to-text endpoints (#39303) (#39322) --- api/controllers/console/explore/trial.py | 2 +- api/controllers/service_api/app/audio.py | 2 +- api/controllers/web/audio.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/api/controllers/console/explore/trial.py b/api/controllers/console/explore/trial.py index e974d290414..67ff9708959 100644 --- a/api/controllers/console/explore/trial.py +++ b/api/controllers/console/explore/trial.py @@ -645,7 +645,7 @@ class TrialChatAudioApi(TrialAppResource): def post(self, current_user: Account, trial_app): app_model = trial_app - file = request.files["file"] + file = request.files.get("file") try: # Get IDs before they might be detached from session diff --git a/api/controllers/service_api/app/audio.py b/api/controllers/service_api/app/audio.py index 1799eb68070..44bea189553 100644 --- a/api/controllers/service_api/app/audio.py +++ b/api/controllers/service_api/app/audio.py @@ -101,7 +101,7 @@ class AudioApi(Resource): Accepts an audio file upload and returns the transcribed text. """ - file = request.files["file"] + file = request.files.get("file") try: response = AudioService.transcript_asr( diff --git a/api/controllers/web/audio.py b/api/controllers/web/audio.py index 3e5c939968c..a7b4fa38916 100644 --- a/api/controllers/web/audio.py +++ b/api/controllers/web/audio.py @@ -76,7 +76,7 @@ class AudioApi(WebApiResource): @web_ns.response(200, "Success", web_ns.models[AudioToTextResponse.__name__]) def post(self, app_model: App, end_user: EndUser): """Convert audio to text""" - file = request.files["file"] + file = request.files.get("file") try: response = AudioService.transcript_asr(