Skip to content

Commit 0a744f6

Browse files
committed
fix(api): use task_instance_id in heartbeat 410 path and align detail message
- Replace undefined ti_id_str with task_instance_id in TIH query and log - Use task_instance_id (UUID) for TIH.task_instance_id comparison - Set 410 Gone detail message to match test expectation
1 parent f228b10 commit 0a744f6

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

airflow-core/src/airflow/api_fastapi/execution_api/routes/task_instances.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -595,18 +595,18 @@ def ti_heartbeat(
595595
# If it does, it was likely cleared while running, so return 410 Gone
596596
# instead of 404 Not Found to give the client a more specific signal.
597597
tih_exists = session.scalar(
598-
select(func.count(TIH.task_instance_id)).where(TIH.task_instance_id == ti_id_str)
598+
select(func.count(TIH.task_instance_id)).where(TIH.task_instance_id == task_instance_id)
599599
)
600600
if tih_exists:
601601
log.error(
602602
"TaskInstance was previously cleared and archived in history, heartbeat skipped",
603-
ti_id=ti_id_str,
603+
ti_id=str(task_instance_id),
604604
)
605605
raise HTTPException(
606606
status_code=status.HTTP_410_GONE,
607607
detail={
608608
"reason": "not_found",
609-
"message": "Task Instance not found",
609+
"message": "Task Instance not found, it may have been moved to the Task Instance History table",
610610
},
611611
)
612612
log.error("Task Instance not found")

0 commit comments

Comments
 (0)