This is an automated email from the ASF dual-hosted git repository.
kaxilnaik pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 485ef131b9a Add deserialization for `access_control` (#49011)
485ef131b9a is described below
commit 485ef131b9aa3de7fdbda7eaba18dc7580a63d9d
Author: Zach Liu <[email protected]>
AuthorDate: Thu Apr 10 04:33:02 2025 -0400
Add deserialization for `access_control` (#49011)
We are passing `dag.access_control` in
https://github.com/apache/airflow/blob/main/airflow-core/src/airflow/dag_processing/collection.py#L223.
In case `dag` is a `LazyDeserializedDAG`, it contains additional properties
such as `__var` which then fails down the road
[here](https://github.com/apache/airflow/blob/main/providers/fab/src/airflow/providers/fab/auth_manager/security_manager/override.py#L1020)
and causes
```
processor-1 | Traceback (most recent call last):
processor-1 | File
"/usr/local/airflow/.local/lib/python3.12/site-packages/airflow/dag_processing/collection.py",
line 202, in _serialize_dag_capturing_errors
processor-1 | _sync_dag_perms(dag, session=session)
processor-1 | File
"/usr/local/airflow/.local/lib/python3.12/site-packages/airflow/dag_processing/collection.py",
line 222, in _sync_dag_perms
processor-1 | security_manager.sync_perm_for_dag(dag_id,
dag.access_control)
processor-1 | File
"/usr/local/airflow/.local/lib/python3.12/site-packages/airflow/providers/fab/auth_manager/security_manager/override.py",
line 964, in sync_perm_for_dag
processor-1 | self._sync_dag_view_permissions(dag_id,
copy.copy(access_control))
processor-1 | File
"/usr/local/airflow/.local/lib/python3.12/site-packages/airflow/providers/fab/auth_manager/security_manager/override.py",
line 1035, in _sync_dag_view_permissions
processor-1 | raise AirflowException(
processor-1 | airflow.exceptions.AirflowException: The access_control
mapping for DAG 'my_dag' includes a role named '__var', but that role does not
exist
```
---
airflow-core/src/airflow/serialization/serialized_objects.py | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/airflow-core/src/airflow/serialization/serialized_objects.py
b/airflow-core/src/airflow/serialization/serialized_objects.py
index a032a453947..7512f0bf244 100644
--- a/airflow-core/src/airflow/serialization/serialized_objects.py
+++ b/airflow-core/src/airflow/serialization/serialized_objects.py
@@ -1944,6 +1944,10 @@ class LazyDeserializedDAG(pydantic.BaseModel):
# This function is complex to implement, for now we delegate
deserialize the dag and delegate to that.
return self._real_dag.next_dagrun_info(*args, **kwargs)
+ @property
+ def access_control(self) -> Mapping[str, Mapping[str, Collection[str]] |
Collection[str]] | None:
+ return
BaseSerialization.deserialize(self.data["dag"].get("access_control"))
+
@cached_property
def _real_dag(self):
return SerializedDAG.from_dict(self.data)
@@ -2005,11 +2009,6 @@ class LazyDeserializedDAG(pydantic.BaseModel):
return data_interval
- if TYPE_CHECKING:
- access_control: Mapping[str, Mapping[str, Collection[str]] |
Collection[str]] | None = pydantic.Field(
- init=False, default=None
- )
-
@attrs.define()
class XComOperatorLink(LoggingMixin):