contributing-docs/19_execution_api_versioning.rst
.. Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
.. http://www.apache.org/licenses/LICENSE-2.0
.. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Airflow's Task Execution API uses Cadwyn <https://github.com/zmievsa/cadwyn>_ for API versioning with CalVer.
This allows us to maintain backward compatibility while evolving the API over time.
Airflow components (e.g., workers, API servers) could be deployed independently. This can lead to version mismatches—for example, a worker using Task SDK 1.0.0 (requiring Airflow >=3.0.0) while the API server has been upgraded to 3.0.1. Without versioning, such mismatches can cause runtime failures or subtle bugs. Enforcing a clear versioning contract ensures backward compatibility and allows for safe, incremental upgrades across different components.
Note: We're prioritizing backward compatibility, older clients should continue to work seamlessly with newer servers. Since the client (Task SDK) and server (API) are still coupled, we can look at forward compatibility once we have a clear versioning strategy between Task SDK and Airflow Core.
When making changes to the Execution API, you must:
Add a new migration module (e.g., v2025_04_28.py). Pick a likely date for when the Airflow version
will be released.
vYYYY_MM_DD format.Document the changes in the migration.
Update tests to cover both old and new versions.
Ensure backward compatibility wherever possible.
Here's an example of how to add a new version migration that adds a new field consumed_asset_events to the
DagRun model.
.. code-block:: python
from cadwyn import ResponseInfo, VersionChange, convert_response_to_previous_version_for, schema
from airflow.api_fastapi.execution_api.datamodels.taskinstance import DagRun, TIRunContext
class AddConsumedAssetEventsField(VersionChange):
"""Add the `consumed_asset_events` to DagRun model."""
description = __doc__
instructions_to_migrate_to_previous_version = (schema(DagRun).field("consumed_asset_events").didnt_exist,)
@convert_response_to_previous_version_for(TIRunContext) # type: ignore
def remove_consumed_asset_events(response: ResponseInfo): # type: ignore
response.body["dag_run"].pop("consumed_asset_events")
The Execution API versioning code is organized as follows:
airflow-core/src/airflow/api_fastapi/execution_api/versions/ - Contains version migrationsairflow-core/src/airflow/api_fastapi/execution_api/versions/head/ - Contains the latest version modelsairflow-core/src/airflow/api_fastapi/execution_api/versions/v2025_04_28/ - Contains version-specific models and migrationsairflow-core/tests/unit/api_fastapi/execution_api/versions/head - Contains tests for the latest versionairflow-core/tests/unit/api_fastapi/execution_api/versions/v2025_04_28 - Contains tests for the version-specific modelsFor an example of how to implement version changes, see:
PR #50528 <https://github.com/apache/airflow/pull/50528>_PR #48125 <https://github.com/apache/airflow/pull/48125>_Cadwyn Documentation <https://docs.cadwyn.dev/>_Cadwyn GitHub Repository <https://github.com/zmievsa/cadwyn>_Cadwyn Version Changes Guide <https://docs.cadwyn.dev/concepts/version_changes/>_