This is an automated email from the ASF dual-hosted git repository.

jedcunningham 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 7c633b6f8f6 Fix RESOURCE_ASSET compatibility with Airflow 2.x in 
common-compat (#64933)
7c633b6f8f6 is described below

commit 7c633b6f8f66681599387d0fbf564c3301eba829
Author: Jed Cunningham <[email protected]>
AuthorDate: Sat Apr 11 17:26:03 2026 -0600

    Fix RESOURCE_ASSET compatibility with Airflow 2.x in common-compat (#64933)
    
    PR #63335 hardcoded RESOURCE_ASSET = "Assets" in this compat module,
    which broke Airflow 2.x deployments. In Airflow 2.x, the equivalent
    resource is named "Datasets" (RESOURCE_DATASET), not "Assets".
    
    apache-airflow-providers-fab imports RESOURCE_ASSET from this module at
    runtime (via the `else` branch of an `if TYPE_CHECKING` block).
    When RESOURCE_ASSET resolves to "Assets" instead of "Datasets", it creates
    duplicate "Assets" and "Datasets" resource types for upgraded instances.
    And worse "Assets", which dont even exist in AF2, are used for auth checks.
    This also breaks any custom roles.
    
    Fix: use AIRFLOW_V_3_0_PLUS to return the correct value for each
    version, falling back to RESOURCE_DATASET from airflow.security.permissions
    (which is not deprecated in Airflow 2.x) for the Airflow 2.x case.
    
    Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
---
 .../src/airflow/providers/common/compat/security/permissions.py  | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git 
a/providers/common/compat/src/airflow/providers/common/compat/security/permissions.py
 
b/providers/common/compat/src/airflow/providers/common/compat/security/permissions.py
index a1e89802278..4f6cba3660f 100644
--- 
a/providers/common/compat/src/airflow/providers/common/compat/security/permissions.py
+++ 
b/providers/common/compat/src/airflow/providers/common/compat/security/permissions.py
@@ -16,8 +16,15 @@
 # under the License.
 from __future__ import annotations
 
+from airflow.providers.common.compat.version_compat import AIRFLOW_V_3_0_PLUS
+
 # Resource Constants
 RESOURCE_BACKFILL = "Backfills"
 RESOURCE_DAG_VERSION = "DAG Versions"
-RESOURCE_ASSET = "Assets"
 RESOURCE_ASSET_ALIAS = "Asset Aliases"
+if AIRFLOW_V_3_0_PLUS:
+    RESOURCE_ASSET = "Assets"
+else:
+    from airflow.security.permissions import (  # type: ignore[attr-defined, 
no-redef]
+        RESOURCE_DATASET as RESOURCE_ASSET,  # noqa: F401
+    )

Reply via email to