From 14b4c83dc654cb3b6ac1f4cbf6d479bcaa00d165 Mon Sep 17 00:00:00 2001 From: eloijrseganfredo Date: Fri, 27 Feb 2026 07:12:03 -0300 Subject: [PATCH] fix: Prevent AudioTranscriptionJob from crashing on OpenAI 401 error (#13653) Describe the bug In v4.8.0, when an audio message is received, the system enqueues Messages::AudioTranscriptionJob even if OpenAI and Captain are disabled. This causes a Faraday::UnauthorizedError (401) which crashes the Sidekiq job and breaks the pipeline for that message. To Reproduce Disable OpenAI/Captain integrations. Send an audio message to an inbox. Check Sidekiq logs and observe the 401 crash in AudioTranscriptionService. What this PR does Adds a rescue Faraday::UnauthorizedError block inside AudioTranscriptionService#perform. Instead of crashing the worker, it logs a warning and gracefully exits, allowing the job to complete successfully. Note: This fixes the backend crash. However, there is still a frontend reactivity issue where the audio player UI requires an F5 to load the media, which has been reported in Issue #11013. --------- Co-authored-by: Eloi Junior Seganfredo Co-authored-by: Aakash Bakhle <48802744+aakashb95@users.noreply.github.com> Co-authored-by: Muhsin Keloth --- .../app/services/messages/audio_transcription_service.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/enterprise/app/services/messages/audio_transcription_service.rb b/enterprise/app/services/messages/audio_transcription_service.rb index 4aa156f47..0e574cb03 100644 --- a/enterprise/app/services/messages/audio_transcription_service.rb +++ b/enterprise/app/services/messages/audio_transcription_service.rb @@ -19,6 +19,9 @@ class Messages::AudioTranscriptionService< Llm::LegacyBaseOpenAiService transcriptions = transcribe_audio Rails.logger.info "Audio transcription successful: #{transcriptions}" { success: true, transcriptions: transcriptions } + rescue Faraday::UnauthorizedError + Rails.logger.warn('Skipping audio transcription: OpenAI configuration is invalid or disabled (401 Unauthorized).') + { error: 'OpenAI configuration is invalid or disabled (401)' } end private