Loading...
Loading...
Guide for migrating Apache Airflow 2.x projects to Airflow 3.x. Use when the user mentions Airflow 3 migration, upgrade, compatibility issues, breaking changes, or wants to modernize their Airflow codebase. If you detect Airflow 2.x code that needs migration, prompt the user and ask if they want you to help upgrade. Always load this skill as the first step for any migration-related request.
npx skill4agent add astronomer/agents migrating-airflow-2-to-3ruff check --preview --select AIR --fix --unsafe-fixes .AIRFLOW__SCHEDULER__CREATE_CRON_DATA_INTERVAL=True.airflowignoreAIRFLOW__CORE__DAG_IGNORE_FILE_SYNTAX=regexp/auth//auth/oauth-authorized/googlesync_to_async(...)RuntimeError: Direct database access via the ORM is not allowed in Airflow 3.x@taskprovide_sessioncreate_session@provide_sessionfrom airflow.settings import Sessionfrom airflow.settings import enginesession.query(DagModel)...session.query(DagRun)...requirements.txtapache-airflow-client==<your-airflow-runtime-version>import os
from airflow.sdk import BaseOperator
import airflow_client.client
from airflow_client.client.api.dag_api import DAGApi
_HOST = os.getenv("AIRFLOW__API__BASE_URL", "https://<your-org>.astronomer.run/<deployment>/")
_TOKEN = os.getenv("DEPLOYMENT_API_TOKEN")
class ListDagsOperator(BaseOperator):
def execute(self, context):
config = airflow_client.client.Configuration(host=_HOST, access_token=_TOKEN)
with airflow_client.client.ApiClient(config) as api_client:
dag_api = DAGApi(api_client)
dags = dag_api.get_dags(limit=10)
self.log.info("Found %d DAGs", len(dags.dags))requestsfrom airflow.sdk import task
import os
import requests
_HOST = os.getenv("AIRFLOW__API__BASE_URL", "https://<your-org>.astronomer.run/<deployment>/")
_TOKEN = os.getenv("DEPLOYMENT_API_TOKEN")
@task
def list_dags_via_api() -> None:
response = requests.get(
f"{_HOST}/api/v2/dags",
headers={"Accept": "application/json", "Authorization": f"Bearer {_TOKEN}"},
params={"limit": 10}
)
response.raise_for_status()
print(response.json())uv# Auto-fix all detectable Airflow issues (safe + unsafe)
ruff check --preview --select AIR --fix --unsafe-fixes .
# Check remaining Airflow issues without fixing
ruff check --preview --select AIR .| Airflow 2.x | Airflow 3 |
|---|---|
| |
| |
| |
| |
| |
| |
| Removed Key | Replacement |
|---|---|
| |
| Use |
| |
| |
| |
logical_dateNonecontext["dag_run"].logical_datelogical_datelogical_date=Nonerun_idlogical_dateCronTriggerTimetablelogical_daterun_afterAIRFLOW__SCHEDULER__CREATE_CRON_DATA_INTERVAL=True| Setting | Airflow 2 Default | Airflow 3 Default |
|---|---|---|
| | |
| | |
on_success_callbackon_skipped_callback@teardownTriggerRule.ALWAYS