Skip to content

[PM-804] fix(parse): support airflow.sdk Variable in astro dev parse#2003

Merged
jlaneve merged 3 commits intomainfrom
agent/pm-804
Mar 4, 2026
Merged

[PM-804] fix(parse): support airflow.sdk Variable in astro dev parse#2003
jlaneve merged 3 commits intomainfrom
agent/pm-804

Conversation

@jlaneve
Copy link
Contributor

@jlaneve jlaneve commented Jan 30, 2026

Summary

  • Extends the Variable.get monkey patch to also apply to airflow.sdk.Variable
  • Ensures astro dev parse works correctly for DAGs using the new Airflow 3.x recommended import style (from airflow.sdk import Variable)
  • Fixes "Variable not found" errors when using remote backends like Azure Key Vault during parse

Context

Customer upgrading from Airflow 3.1.2 to 3.1.3 was blocked because astro dev parse fails when DAGs use airflow.sdk Variable.get with Azure Key Vault as the backend.

The existing test harness only monkey-patched airflow.models.Variable.get, so when imports are updated to use airflow.sdk (the new recommended approach in Airflow 3.x), the parse step makes real calls and fails with Variable not found.

Verified locally

Tested with Runtime 3.1-7 using DAGs that call Variable.get at the top level (parse time):

DAG import style main (before) This PR (after)
from airflow.models import Variable Passed Passed
from airflow.sdk import Variable FAILEDAirflowRuntimeError: VARIABLE_NOT_FOUND Passed

On main, airflow.sdk.Variable.get bypasses the monkeypatch and makes a real call, which throws VARIABLE_NOT_FOUND. This PR patches both airflow.models.Variable and airflow.sdk.Variable so both import styles work.

Test plan

  • Verify astro dev parse works with DAGs using from airflow.sdk import Variable
  • Verify astro dev parse still works with DAGs using from airflow.models import Variable
  • Tested with Airflow Runtime 3.1-7

🤖 Generated with Claude Code

Astro Code Agent and others added 2 commits January 30, 2026 18:19
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 <noreply@anthropic.com>
@coveralls-official
Copy link

coveralls-official bot commented Jan 30, 2026

Pull Request Test Coverage Report for Build ca25f6ef-09ee-4b86-8f62-56da18f6a541

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 33.153%

Totals Coverage Status
Change from base Build 055b4403-e142-4b85-a4c3-69b561e6393f: 0.0%
Covered Lines: 20868
Relevant Lines: 62944

💛 - Coveralls

@jlaneve jlaneve marked this pull request as ready for review January 30, 2026 18:42
@jlaneve jlaneve requested a review from a team as a code owner February 7, 2026 18:10
@jlaneve jlaneve merged commit 3f953fb into main Mar 4, 2026
5 of 6 checks passed
@jlaneve jlaneve deleted the agent/pm-804 branch March 4, 2026 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants