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 <eloi@seganfredo.local> Co-authored-by: Aakash Bakhle <48802744+aakashb95@users.noreply.github.com> Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user