You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "jedcunningham (via GitHub)" <gi...@apache.org> on 2026/04/08 23:10:02 UTC

[PR] Fix RESOURCE_ASSET compatibility with Airflow 2.x in common-compat [airflow]

jedcunningham opened a new pull request, #64933:
URL: https://github.com/apache/airflow/pull/64933

   ## Summary
   
   Fixes a regression introduced by #63335, which hardcoded `RESOURCE_ASSET = "Assets"`
   in `providers/common/compat/security/permissions.py`. This value is correct for
   Airflow 3, but breaks Airflow 2.x in two ways:
   
   1. **Wrong resource name in Airflow 2.x.** `apache-airflow-providers-fab` imports
      `RESOURCE_ASSET` from this module at runtime. FAB's role sync updates stock roles
      to grant the `"Assets"` resource, but the correct Airflow 2.x name is `"Datasets"`.
      This creates an inconsistency and pollutes the permission model with a resource that
      doesn't belong in Airflow 2.x.
   
   2. **Custom roles break.** Any role with `"Datasets"` permissions stops working, since
      auth checks now look for `"Assets"`. While you could re-grant permissions against
      `"Assets"` after upgrading, existing roles are silently broken.
   
   ## Fix
   
   Gate on `AIRFLOW_V_3_0_PLUS`: return `"Assets"` for Airflow 3, and fall back to
   `RESOURCE_DATASET` from `airflow.security.permissions` (not deprecated in Airflow 2.x)
   for Airflow 2.x.
   
   ## Related
   
   - Reverts the behavioral change from: #63335
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix RESOURCE_ASSET compatibility with Airflow 2.x in common-compat [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #64933:
URL: https://github.com/apache/airflow/pull/64933#issuecomment-4217596539

   There is a mypy issue for providers :( 


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix RESOURCE_ASSET compatibility with Airflow 2.x in common-compat [airflow]

Posted by "jedcunningham (via GitHub)" <gi...@apache.org>.
jedcunningham merged PR #64933:
URL: https://github.com/apache/airflow/pull/64933


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix RESOURCE_ASSET compatibility with Airflow 2.x in common-compat [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #64933:
URL: https://github.com/apache/airflow/pull/64933#issuecomment-4210403721

   BTW. I **do** think that the `if AIRFLOW*` pattern with version is way bettter than "Pythonic" try/except - and this is the reason I was pushing for it @ashb (and @xBis7 as you asked) -  the main reason for having this pattern is to **know** exactly when you can remove it - one of the reasons this one happened was that it was not at all clear if we can remove that try/remove.
   
   Also we will have to find out why this was not detected by compatibility tests - it should have been, but possibly this kind of issue was masked by something.  To be diagnosed.


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix RESOURCE_ASSET compatibility with Airflow 2.x in common-compat [airflow]

Posted by "jedcunningham (via GitHub)" <gi...@apache.org>.
jedcunningham commented on PR #64933:
URL: https://github.com/apache/airflow/pull/64933#issuecomment-4215296830

   I suspect it wasn't found in the compatibility tests because it caused "Assets" resources and permissions to be created alongside the "Dataset" ones that should have been used. And if you didn't have a custom role (or maybe modified the existing roles) without the dataset perms, its hidden because it "just works", even if its fundamentally wrong.


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix RESOURCE_ASSET compatibility with Airflow 2.x in common-compat [airflow]

Posted by "jedcunningham (via GitHub)" <gi...@apache.org>.
jedcunningham commented on PR #64933:
URL: https://github.com/apache/airflow/pull/64933#issuecomment-4215408661

   An example after the upgrade (all default roles get this) (this is before this fix of course):
   
   <img width="1506" height="678" alt="Screenshot 2026-04-09 at 9 23 27 AM" src="https://github.com/user-attachments/assets/a5e84f9f-54f7-4eff-9063-ebd0c39a2834" />
   


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix RESOURCE_ASSET compatibility with Airflow 2.x in common-compat [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #64933:
URL: https://github.com/apache/airflow/pull/64933#issuecomment-4210392283

   I guess that means rc2 for common.compat and the two providers that depend on it's new version from the current vote. Thanks for finding and fixing!


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix RESOURCE_ASSET compatibility with Airflow 2.x in common-compat [airflow]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #64933:
URL: https://github.com/apache/airflow/pull/64933#discussion_r3066484873


##########
providers/common/compat/src/airflow/providers/common/compat/security/permissions.py:
##########
@@ -16,8 +16,16 @@
 # 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 (
+        RESOURCE_DATASET as RESOURCE_ASSET,  # noqa: F401  # type: ignore[attr-defined, no-redef]
+    )

Review Comment:
   The conditional import of `RESOURCE_DATASET` happens after module-level assignments (`RESOURCE_BACKFILL`, etc.), which will trigger Ruff E402 (imports not at top of file) for this module. To avoid CI/lint failures, move the `if AIRFLOW_V_3_0_PLUS` block (and the import) above the resource constant assignments, or otherwise ensure the import occurs before any non-import statements (alternatively, use a literal string for the AF2 value if you want to avoid conditional importing).



##########
providers/common/compat/src/airflow/providers/common/compat/security/permissions.py:
##########
@@ -16,8 +16,16 @@
 # 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 (
+        RESOURCE_DATASET as RESOURCE_ASSET,  # noqa: F401  # type: ignore[attr-defined, no-redef]
+    )

Review Comment:
   This change fixes a version-dependent permission constant, but there’s no regression test that asserts the *value* of `RESOURCE_ASSET` for the running Airflow major version (the existing import-only test won’t catch the Airflow 2.x vs 3.x mismatch). Add an assertion-based unit test that checks the expected value under Airflow 2.x vs 3.x (e.g., branch on `AIRFLOW_V_3_0_PLUS`).



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org