kaxil commented on code in PR #70138:
URL: https://github.com/apache/airflow/pull/70138#discussion_r3756161393


##########
airflow-core/tests/unit/api_fastapi/execution_api/versions/v2026_06_30/test_dag_runs.py:
##########
@@ -0,0 +1,88 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from __future__ import annotations
+
+import pytest
+
+from airflow._shared.timezones import timezone
+from airflow.utils.state import DagRunState
+
+pytestmark = pytest.mark.db_test
+
+ADDED_IN_2026_06_30 = frozenset({"team_name", "partition_date"})
+
+
[email protected]
+def old_ver_client(client):
+    """Last released execution API before ``team_name`` and ``partition_date`` 
were added."""
+    client.headers["Airflow-API-Version"] = "2026-04-06"
+    return client
+
+
[email protected]
+def dag_runs(session, dag_maker):
+    with dag_maker(dag_id="test_dag_run_fields", session=session, 
serialized=True):
+        pass
+    dag_maker.create_dagrun(
+        state=DagRunState.SUCCESS,
+        logical_date=timezone.datetime(2025, 1, 1),
+        run_id="run1",
+    )
+    dag_maker.create_dagrun(
+        state=DagRunState.SUCCESS,
+        logical_date=timezone.datetime(2025, 1, 10),
+        run_id="run2",
+    )
+    session.commit()

Review Comment:
   Neither fixture run sets `partition_date`, so both fields are `None` here 
and a value-gated converter (pop only when the value is falsy) would pass all 
three tests while still 500-ing a 2026-04-06 client on a partitioned Dag. 
`partition_date` is a real column, so setting it on one run before the commit 
closes that gap, the same way 
`test_old_version_strips_partition_date_from_dag_run` does in the sibling 
`test_task_instances.py`.
   
   Worth noting `team_name` can't be exercised here at all -- it isn't a 
`DagRun` column, just a transient attribute the TIRunContext route assigns, so 
on these two routes it is always `None`.
   



##########
airflow-core/src/airflow/api_fastapi/execution_api/versions/v2026_06_30.py:
##########
@@ -99,6 +99,20 @@ def remove_team_name_field(response: ResponseInfo) -> None:  
# type: ignore[misc
         if "dag_run" in response.body and isinstance(response.body["dag_run"], 
dict):
             response.body["dag_run"].pop("team_name", None)
 
+    @convert_response_to_previous_version_for(DagRun)  # type: ignore[arg-type]
+    def remove_team_name_from_dag_run(response: ResponseInfo) -> None:  # 
type: ignore[misc]

Review Comment:
   `remove_team_name_from_dag_run` reads like the nested-`dag_run` converter, 
which is what `remove_partition_date_from_dag_run` further down actually is. 
The new partition_date one dodged that with a `_response` suffix, so matching 
it here keeps the file readable for the next person adding a field.
   



##########
airflow-core/src/airflow/api_fastapi/execution_api/versions/v2026_06_30.py:
##########
@@ -99,6 +99,20 @@ def remove_team_name_field(response: ResponseInfo) -> None:  
# type: ignore[misc
         if "dag_run" in response.body and isinstance(response.body["dag_run"], 
dict):
             response.body["dag_run"].pop("team_name", None)
 
+    @convert_response_to_previous_version_for(DagRun)  # type: ignore[arg-type]
+    def remove_team_name_from_dag_run(response: ResponseInfo) -> None:  # 
type: ignore[misc]
+        """Remove the ``team_name`` field from responses returning a DagRun 
directly."""
+        if isinstance(response.body, dict):
+            response.body.pop("team_name", None)
+
+    # Schema-based converters are matched against the route's response model 
by identity, so a
+    # route annotated ``DagRun | None`` never matches ``DagRun`` and has to be 
addressed by path.
+    @convert_response_to_previous_version_for("/dag-runs/previous", ["GET"])  
# type: ignore[arg-type]

Review Comment:
   Agreed on scope, and thanks for the correction -- I confirmed it. With the 
four converters reverted, both routes raise 
`fastapi.exceptions.ResponseValidationError` (`extra_forbidden` on 
`team_name`/`partition_date`), so a 2026-04-06 worker gets a 500 from the API 
server, not the client-side error the description describes. Worth fixing that 
in the body, since the signature an operator would grep for is 
`extra_forbidden` in api-server logs.
   
   On the compat route, I checked the delta and you're right that it's 
separable: 3.2.0 shipped with no path converters in `v2026_04_06.py` and the 
route still un-annotated, so a `task-sdk` 1.1.8 worker pinning 2025-11-05 
already fails there on `note`/`partition_key` -- two more fields don't change 
that, and it needs its own fix covering all of them.
   



-- 
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]

Reply via email to