Copilot commented on code in PR #68012:
URL: https://github.com/apache/airflow/pull/68012#discussion_r3492384333
##########
task-sdk/src/airflow/sdk/execution_time/schema/versions/__init__.py:
##########
@@ -20,6 +20,11 @@
import functools
from typing import TYPE_CHECKING, Any
+bundle = VersionBundle(
+ HeadVersion(),
+ # First supervisor schema version; there is no previous version to migrate
from.
+ Version("2026-06-16"),
+)
if TYPE_CHECKING:
from cadwyn import VersionBundle
Review Comment:
`bundle = VersionBundle(...)` is executed at import time, but
`VersionBundle`/`HeadVersion`/`Version` are only imported inside `get_bundle()`
(and `VersionBundle` is only imported under `TYPE_CHECKING`). This makes
importing this module raise `NameError` immediately, defeating the intended
lazy import behavior.
##########
airflow-core/src/airflow/api_fastapi/execution_api/routes/task_instances.py:
##########
@@ -296,6 +296,14 @@ def ti_run(
)
or 0
)
+ first_task_reschedule_start_date = None
+ if task_reschedule_count > 0:
+ first_task_reschedule_start_date = session.scalar(
+ select(TaskReschedule.start_date)
+ .where(TaskReschedule.ti_id == task_instance_id)
+ .order_by(TaskReschedule.id.asc())
+ .limit(1)
+ )
Review Comment:
The query intended to return the *first* reschedule start date orders by
`TaskReschedule.id`. If reschedule rows can be inserted out-of-order (e.g.
backfill/manual edits), this can return a non-earliest `start_date`. Using
`min(start_date)` (or ordering by `start_date`) matches the field semantics
more directly.
##########
airflow-core/tests/unit/api_fastapi/execution_api/versions/v2026_06_30/test_task_instances.py:
##########
@@ -46,6 +62,55 @@ def old_ver_client(client):
return client
[email protected](autouse=True)
+def setup_teardown():
+ clear_db_runs()
+ clear_db_serialized_dags()
+ clear_db_dags()
+ yield
+ clear_db_runs()
+ clear_db_serialized_dags()
+ clear_db_dags()
+
+
+def test_first_task_reschedule_start_date_removed_from_previous_version(
+ old_ver_client,
+ session,
+ create_task_instance,
+):
+ ti = create_task_instance(
+
task_id="test_first_task_reschedule_start_date_removed_from_previous_version",
+ state=State.QUEUED,
+ dagrun_state=DagRunState.RUNNING,
+ session=session,
+ start_date=timezone.datetime(2024, 9, 30, 12),
+ dag_id=str(uuid4()),
+ )
+ session.add(
+ TaskReschedule(
+ ti_id=ti.id,
+ start_date=timezone.datetime(2024, 9, 30, 10),
+ end_date=timezone.datetime(2024, 9, 30, 10, 1),
+ reschedule_date=timezone.datetime(2024, 9, 30, 10, 2),
+ )
+ )
+ session.commit()
+
+ response = old_ver_client.patch(
+ f"/execution/task-instances/{ti.id}/run",
+ json={
+ "state": "running",
+ "hostname": "random-hostname",
+ "unixname": "random-unixname",
+ "pid": 100,
+ "start_date": "2024-09-30T12:00:00Z",
+ },
+ )
+
+ assert response.status_code == 200
+ result = response.json()
+ assert result["task_reschedule_count"] == 1
+ assert "first_task_reschedule_start_date" not in result
class TestPartitionDateFieldBackwardCompat:
Review Comment:
PEP8/ruff expects two blank lines between top-level definitions. Add blank
lines between the end of
`test_first_task_reschedule_start_date_removed_from_previous_version` and the
`TestPartitionDateFieldBackwardCompat` class to avoid style-check failures.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]