kaxil commented on code in PR #72327:
URL: https://github.com/apache/airflow/pull/72327#discussion_r3963892349
##########
airflow-core/tests/unit/api_fastapi/execution_api/versions/v2026_06_30/test_dag_runs.py:
##########
@@ -88,3 +91,53 @@ def
test_get_previous_dag_run_without_a_match(old_ver_client):
assert response.status_code == 200
assert response.json() is None
+
+
[email protected]
+def dag_run_with_consumed_event(session, dag_maker):
+ """A Dag run that consumed an asset event carrying a ``partition_key``."""
+ # dag_maker resets Dag/DagRun tables between tests but not asset tables,
and this fixture
+ # commits (the API request needs to see the row), so a leftover asset from
a prior test
+ # using this fixture would collide on the name/uri unique constraint.
+ clear_db_assets()
+ with dag_maker(dag_id="test_dag_run_consumed_event", session=session,
serialized=True):
+ pass
+ run = dag_maker.create_dagrun(
+ state=DagRunState.SUCCESS,
+ logical_date=timezone.datetime(2025, 1, 1),
+ run_id="run1",
+ )
+ asset = AssetModel(name="upstream", uri="s3://bucket/upstream",
group="asset", extra={})
+ session.add_all([asset, AssetActive.for_asset(asset)])
+ session.flush()
+ run.consumed_asset_events.append(
+ AssetEvent(asset_id=asset.id, source_dag_id="src", source_run_id="r1",
partition_key="2024-01-15")
+ )
+ session.commit()
+ yield
+ clear_db_assets()
+
+
[email protected]("dag_run_with_consumed_event")
+def test_get_dag_run_strips_consumed_event_partition_key(old_ver_client):
+ """A bare-DagRun route must not leak an event-level partition_key to a
pre-2026-06-30 client."""
+ response =
old_ver_client.get("/execution/dag-runs/test_dag_run_consumed_event/run1")
+
+ assert response.status_code == 200
+ assert all("partition_key" not in event for event in
response.json()["consumed_asset_events"])
Review Comment:
`consumed_asset_events` is always `[]` on this route: the handler runs a
plain `select(DagRunModel)` with no `joinedload`, `SessionDep` is a fresh
`create_session(scoped=False)` so the fixture's in-session append is not
visible, and `safe_extract_from_orm` defaults the unloaded relationship. So
this `all(...)` iterates nothing and would pass with the version gate deleted
entirely. Same for the `/previous` test below. Asserting
`response.json()["consumed_asset_events"] == []` would pin the invariant that
actually holds today, and would still fail loudly if a later change adds eager
loading here.
--
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]