rjgoyln commented on code in PR #72862:
URL: https://github.com/apache/airflow/pull/72862#discussion_r4115165322


##########
airflow-core/tests/unit/api_fastapi/core_api/routes/ui/test_assets.py:
##########
@@ -118,6 +119,86 @@ def test_should_response_200(self, test_client, dag_maker):
             "pending_partition_count": None,
         }
 
+    @mock.patch(
+        
"airflow.api_fastapi.auth.managers.base_auth_manager.BaseAuthManager.get_authorized_assets",
+        autospec=True,
+    )
+    def test_should_return_only_assets_the_caller_may_read(
+        self, mock_get_authorized_assets, test_client, dag_maker, session
+    ):
+        with dag_maker(
+            dag_id="hidden_upstream",
+            schedule=[
+                Asset(uri="s3://bucket/visible", name="visible_asset"),
+                Asset(uri="s3://bucket/hidden", name="hidden_asset"),
+            ],
+            serialized=True,
+        ):
+            EmptyOperator(task_id="task1")
+        dag_maker.sync_dagbag_to_db()
+        visible_id = 
session.scalar(select(AssetModel.id).where(AssetModel.name == "visible_asset"))
+        mock_get_authorized_assets.return_value = {visible_id}
+
+        response = test_client.get("/next_run_assets/hidden_upstream")
+
+        mock_get_authorized_assets.assert_called_once_with(mock.ANY, 
user=mock.ANY, method="GET")

Review Comment:
   After the rebase, this assertion no longer distinguishes the change: `main` 
already calls `get_authorized_assets` here for expression redaction, so it 
passes without the `to_orm` line. The `events` assertion below is what fails on 
`main`, so I think this line can be removed.
   



##########
airflow-core/src/airflow/api_fastapi/core_api/routes/ui/assets.py:
##########
@@ -217,6 +218,7 @@ def next_run_assets(
         .group_by(AssetModel.id, AssetModel.uri, AssetModel.name, 
AssetActive.name)
         .order_by(AssetModel.uri)
     )
+    query = readable_assets_filter.to_orm(query)

Review Comment:
   This drops unreadable rows, while #72864 keeps redacted expression slots to 
preserve the schedule shape. `AssetSchedule.tsx` uses `nextRunEvents.length` 
for the count, so a caller who can read 1 of 3 assets will see a one-asset 
trigger, and potentially "2 of 2" for a Dag actually waiting on 3. If we keep 
dropping rows, I think the PR body should note that these counts are now 
caller-scoped and may need a UI follow-up to reconcile them with the redacted 
expression.
   



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