Skip to content

Commit 0ef9c07

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 e5697cb commit 0ef9c07

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
@@ -646,18 +646,18 @@ def ti_heartbeat(
646646
# If it does, it was likely cleared while running, so return 410 Gone
647647
# instead of 404 Not Found to give the client a more specific signal.
648648
tih_exists = session.scalar(
649-
select(func.count(TIH.task_instance_id)).where(TIH.task_instance_id == ti_id_str)
649+
select(func.count(TIH.task_instance_id)).where(TIH.task_instance_id == task_instance_id)
650650
)
651651
if tih_exists:
652652
log.error(
653653
"TaskInstance was previously cleared and archived in history, heartbeat skipped",
654-
ti_id=ti_id_str,
654+
ti_id=str(task_instance_id),
655655
)
656656
raise HTTPException(
657657
status_code=status.HTTP_410_GONE,
658658
detail={
659659
"reason": "not_found",
660-
"message": "Task Instance not found",
660+
"message": "Task Instance not found, it may have been moved to the Task Instance History table",
661661
},
662662
)
663663
log.error("Task Instance not found")

0 commit comments

Comments
 (0)