ChickenBenny commented on code in PR #76583:
URL: https://github.com/apache/airflow/pull/76583#discussion_r4506603778
##########
airflow-core/src/airflow/api_fastapi/core_api/security.py:
##########
@@ -648,7 +651,9 @@ async def inner(
)
# Select the id alongside dag_id: a NULL dag_id and a missing row
both come back
# as None from a bare ``Log.dag_id`` scalar, and they authorize
differently.
- row = session.execute(select(Log.id, Log.dag_id).where(Log.id ==
event_log_id)).one_or_none()
+ row = (
+ await session.execute(select(Log.id, Log.dag_id).where(Log.id
== event_log_id))
Review Comment:
If this follows #76493's approach, the end of `requires_access_event_log`
would match the end of `requires_access_backfill` there, apart from
`access_entity`:
```python
team_name = await DagModel.get_team_name_async(dag_id, session=session) if
dag_id else None
_requires_access(
is_authorized_callback=lambda: get_auth_manager().is_authorized_dag(
method=method,
access_entity=DagAccessEntity.AUDIT_LOG, # RUN in
requires_access_backfill
details=DagDetails(id=dag_id, team_name=team_name),
user=user,
)
)
```
Would it make sense to move that into a small async helper, something like
`_authorize_dag_async(method, access_entity, dag_id, user, *, session=...)`, so
both async dependencies share it? `requires_access_dag` itself could stay sync,
since `Depends` runs it in the threadpool.
--
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]