From 72cd0e50ad6d7fe32f38769c376cd36a23978504 Mon Sep 17 00:00:00 2001 From: Astro Code Agent Date: Fri, 30 Jan 2026 18:19:29 +0000 Subject: [PATCH 1/2] fix(parse): support airflow.sdk Variable in astro dev parse When DAGs use the new Airflow 3.x recommended import style `from airflow.sdk import Variable`, the existing monkey patch for `airflow.models.Variable.get` was not being applied. This caused `astro dev parse` to fail with "Variable not found" errors when using remote backends like Azure Key Vault. This fix extends the Variable.get monkey patch to also apply to `airflow.sdk.Variable`, ensuring DAG parsing works correctly for both the legacy `airflow.models.Variable` and the new `airflow.sdk.Variable` import styles. Fixes PM-804 Co-Authored-By: Claude Opus 4.5 --- airflow/include/airflow3/dagintegritytestdefault.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/airflow/include/airflow3/dagintegritytestdefault.py b/airflow/include/airflow3/dagintegritytestdefault.py index 9f5a7cc98..c360c93b0 100644 --- a/airflow/include/airflow3/dagintegritytestdefault.py +++ b/airflow/include/airflow3/dagintegritytestdefault.py @@ -81,6 +81,15 @@ def variable_get_monkeypatch(key: str, default_var=_no_default, deserialize_json Variable.get = variable_get_monkeypatch + +# Also patch airflow.sdk.Variable for Airflow 3.x SDK imports +# This ensures DAGs using 'from airflow.sdk import Variable' work with parse +try: + from airflow import sdk as airflow_sdk + if hasattr(airflow_sdk, 'Variable'): + airflow_sdk.Variable.get = variable_get_monkeypatch +except ImportError: + pass # airflow.sdk not available (older Airflow 3.x version) # # =========== /MONKEYPATCH VARIABLE.GET() =========== From 95aced2c401416f5954579361ce2bbc9f30e0892 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 30 Jan 2026 18:20:36 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- airflow/include/airflow3/dagintegritytestdefault.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/airflow/include/airflow3/dagintegritytestdefault.py b/airflow/include/airflow3/dagintegritytestdefault.py index c360c93b0..cdacd724e 100644 --- a/airflow/include/airflow3/dagintegritytestdefault.py +++ b/airflow/include/airflow3/dagintegritytestdefault.py @@ -86,7 +86,8 @@ def variable_get_monkeypatch(key: str, default_var=_no_default, deserialize_json # This ensures DAGs using 'from airflow.sdk import Variable' work with parse try: from airflow import sdk as airflow_sdk - if hasattr(airflow_sdk, 'Variable'): + + if hasattr(airflow_sdk, "Variable"): airflow_sdk.Variable.get = variable_get_monkeypatch except ImportError: pass # airflow.sdk not available (older Airflow 3.x version)