🥅(summary) catch file-related exceptions when handling recording objects

Previously, if a recording file was not found in the bucket, the code would
crash. This adds proper error handling to avoid unhandled failures.
This commit is contained in:
lebaudantoine
2026-02-02 23:42:49 +01:00
committed by aleb_the_flash
parent 716e11b5b3
commit 9f58efb851
3 changed files with 45 additions and 27 deletions

View File

@@ -20,6 +20,7 @@ and this project adheres to
- ♿️(frontend) sr pin/unpin announcements with dedicated messages #898
- ♿(frontend) adjust sr announcements for idle disconnect timer #908
- ♿️(frontend) add global screen reader announcer#922
- 🥅(summary) catch file-related exceptions when handling recording #944
### Fixed

View File

@@ -16,7 +16,7 @@ from urllib3.util import Retry
from summary.core.analytics import MetadataManager, get_analytics
from summary.core.config import get_settings
from summary.core.file_service import FileService
from summary.core.file_service import FileService, FileServiceException
from summary.core.llm_service import LLMException, LLMObservability, LLMService
from summary.core.prompt import (
FORMAT_NEXT_STEPS,
@@ -145,36 +145,41 @@ def process_audio_transcribe_summarize_v2(
max_retries=settings.whisperx_max_retries,
)
with (
file_service.prepare_audio_file(filename) as (audio_file, metadata),
):
metadata_manager.track(task_id, {"audio_length": metadata["duration"]})
try:
with (
file_service.prepare_audio_file(filename) as (audio_file, metadata),
):
metadata_manager.track(task_id, {"audio_length": metadata["duration"]})
if language is None:
language = settings.whisperx_default_language
logger.info(
"No language specified, using default from settings: %s",
(language or "auto-detect"),
)
else:
logger.info(
"Querying transcription in '%s' language",
language,
if language is None:
language = settings.whisperx_default_language
logger.info(
"No language specified, using default from settings: %s",
(language or "auto-detect"),
)
else:
logger.info(
"Querying transcription in '%s' language",
language,
)
transcription_start_time = time.time()
transcription = whisperx_client.audio.transcriptions.create(
model=settings.whisperx_asr_model, file=audio_file, language=language
)
transcription_start_time = time.time()
transcription_time = round(time.time() - transcription_start_time, 2)
metadata_manager.track(
task_id,
{"transcription_time": transcription_time},
)
logger.info("Transcription received in %.2f seconds.", transcription_time)
logger.debug("Transcription: \n %s", transcription)
transcription = whisperx_client.audio.transcriptions.create(
model=settings.whisperx_asr_model, file=audio_file, language=language
)
transcription_time = round(time.time() - transcription_start_time, 2)
metadata_manager.track(
task_id,
{"transcription_time": transcription_time},
)
logger.info("Transcription received in %.2f seconds.", transcription_time)
logger.debug("Transcription: \n %s", transcription)
except FileServiceException:
logger.exception("Unexpected error for filename: %s", filename)
return
metadata_manager.track_transcription_metadata(task_id, transcription)

View File

@@ -8,12 +8,19 @@ from pathlib import Path
import mutagen
from minio import Minio
from minio.error import MinioException, S3Error
from summary.core.config import get_settings
settings = get_settings()
class FileServiceException(Exception):
"""Base exception for file service operations."""
pass
class FileService:
"""Service for downloading and preparing files from MinIO storage."""
@@ -79,6 +86,11 @@ class FileService:
return local_path
except (MinioException, S3Error) as e:
raise FileServiceException(
"Unexpected error while downloading object."
) from e
finally:
if response:
response.close()