Skip to content

Commit

Permalink
Handle empty-history case in mark_last_wftask_as_failed
Browse files Browse the repository at this point in the history
  • Loading branch information
tcompa committed Jan 14, 2025
1 parent d2ebb5a commit 95f6bf7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions fractal_server/app/runner/v2/handle_failed_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ def mark_last_wftask_as_failed(
logger = logging.getLogger(logger_name)
with next(get_sync_db()) as db:
db_dataset = db.get(DatasetV2, dataset_id)
if len(db_dataset.history) == 0:
logger.warning(
f"History for {dataset_id=} is empty. Likely reason: the job "
"failed before its first task was marked as SUBMITTED. "
"Continue."
)
return
workflowtask_id = db_dataset.history[-1]["workflowtask"]["id"]
last_item_status = db_dataset.history[-1]["status"]
if last_item_status != WorkflowTaskStatusTypeV2.SUBMITTED:
Expand Down

0 comments on commit 95f6bf7

Please sign in to comment.