From faec932ef70031f971c20571ecad977a97885853 Mon Sep 17 00:00:00 2001 From: msramalho <19508417+msramalho@users.noreply.github.com> Date: Thu, 23 Apr 2026 14:16:27 +0100 Subject: [PATCH] ads extra try/catch to prevent upstream AA uncaught errors --- app/worker/main.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/app/worker/main.py b/app/worker/main.py index 11671c1..4d7fe0b 100644 --- a/app/worker/main.py +++ b/app/worker/main.py @@ -128,7 +128,21 @@ def create_sheet_task(self, sheet_json: str): ) orchestrator = ArchivingOrchestrator() orchestrator.logger_id = AA_LOGGER_ID # ensure single logger - orchestrator.setup(args) + try: + orchestrator.setup(args) + except SystemExit as e: + log_error(e, "create_sheet_task: SystemExit from AA during setup") + cleanup_orchestrator(orchestrator) + return schemas.CelerySheetTask( + success=False, + sheet_id=sheet.sheet_id, + time=datetime.datetime.now().isoformat(), + stats={"archived": 0, "failed": 0, "errors": [str(e)]}, + ).model_dump() + except Exception as e: + log_error(e, "create_sheet_task: error during orchestrator setup") + cleanup_orchestrator(orchestrator) + raise AA_LOGGER_ID = orchestrator.logger_id stats = {"archived": 0, "failed": 0, "errors": []}