diff --git a/server/reflector/services/transcript_process.py b/server/reflector/services/transcript_process.py index ad469cab..2890e069 100644 --- a/server/reflector/services/transcript_process.py +++ b/server/reflector/services/transcript_process.py @@ -11,6 +11,7 @@ from typing import Literal, Union, assert_never import celery from celery.result import AsyncResult +from hatchet_sdk.clients.rest.exceptions import ApiException from hatchet_sdk.clients.rest.models import V1TaskStatus from reflector.db.recordings import recordings_controller @@ -124,8 +125,8 @@ async def validate_transcript_for_processing( return ValidationAlreadyScheduled( detail="Hatchet workflow already running" ) - except Exception: - # If we can't get status, allow processing (workflow might be gone) + except ApiException: + # Workflow might be gone (404) or API issue - allow processing pass return ValidationOk( @@ -244,8 +245,8 @@ async def dispatch_transcript_processing( workflow_id=transcript.workflow_run_id, ) return None - except Exception: - # If we can't get status, proceed with new workflow + except ApiException: + # Workflow might be gone (404) or API issue - proceed with new workflow pass workflow_id = await HatchetClientManager.start_workflow( diff --git a/server/reflector/tools/process_transcript.py b/server/reflector/tools/process_transcript.py index b0ff7729..8d8b8d04 100644 --- a/server/reflector/tools/process_transcript.py +++ b/server/reflector/tools/process_transcript.py @@ -109,7 +109,7 @@ async def process_transcript( status = await HatchetClientManager.get_workflow_run_status( transcript.workflow_run_id ) - print(f" Status: {status}", file=sys.stderr) + print(f" Status: {status.value}", file=sys.stderr) if status == V1TaskStatus.COMPLETED: print("Workflow completed successfully", file=sys.stderr) diff --git a/server/tests/test_hatchet_dispatch.py b/server/tests/test_hatchet_dispatch.py index 857645ec..57a699ee 100644 --- a/server/tests/test_hatchet_dispatch.py +++ b/server/tests/test_hatchet_dispatch.py @@ -11,6 +11,7 @@ These tests verify: from unittest.mock import AsyncMock, patch import pytest +from hatchet_sdk.clients.rest.exceptions import ApiException from hatchet_sdk.clients.rest.models import V1TaskStatus from reflector.db.transcripts import Transcript @@ -194,7 +195,7 @@ async def test_hatchet_validation_allows_when_status_check_fails(): ) as mock_hatchet: # Status check fails (workflow might be deleted) mock_hatchet.get_workflow_run_status = AsyncMock( - side_effect=Exception("Workflow not found") + side_effect=ApiException("Workflow not found") ) with patch(