Skip to content

Make dag_version_id in TI non-nullable - #50825

Merged
ephraimbuddy merged 39 commits into
apache:mainfrom
astronomer:make-ti-dag-version-id-non-nullable2
Jul 8, 2025
Merged

Make dag_version_id in TI non-nullable#50825
ephraimbuddy merged 39 commits into
apache:mainfrom
astronomer:make-ti-dag-version-id-non-nullable2

Conversation

@ephraimbuddy

Copy link
Copy Markdown
Contributor

Enforces serialization of DAGs before creating DagRuns and TaskInstances.

The changes include:

  • Making dag_version_id a required parameter in TaskInstance constructor
  • Migrating the dag_version_id column in TaskInstance to be non-nullable
  • Adding a check in _create_orm_dagrun to raise AirflowException if dag is not serialized
  • Updating tests to ensure DAGs are properly serialized before creating DagRuns

This prevents running runs with missing serialized DAG versions.

@ephraimbuddy
ephraimbuddyforce-pushed the make-ti-dag-version-id-non-nullable2 branch from 20c6e75 to 08bfa28CompareMay 20, 2025 17:14
@ephraimbuddy
ephraimbuddyforce-pushed the make-ti-dag-version-id-non-nullable2 branch from 9d3fc74 to 63eb72bCompareMay 21, 2025 15:28
@ephraimbuddy
ephraimbuddyforce-pushed the make-ti-dag-version-id-non-nullable2 branch 2 times, most recently from aad0a5f to 80439a1CompareMay 21, 2025 17:35
Comment threadairflow-core/docs/migrations-ref.rst Outdated
Comment threadairflow-core/src/airflow/cli/commands/task_command.py
@ephraimbuddy
ephraimbuddyforce-pushed the make-ti-dag-version-id-non-nullable2 branch 2 times, most recently from 5409839 to 616e0a1CompareMay 24, 2025 22:18
@ephraimbuddy
ephraimbuddyforce-pushed the make-ti-dag-version-id-non-nullable2 branch from 616e0a1 to 070f7a3CompareMay 25, 2025 10:55
@ephraimbuddy
ephraimbuddyforce-pushed the make-ti-dag-version-id-non-nullable2 branch from 564ac88 to f3c6444CompareJuly 8, 2025 15:28
@ephraimbuddy
ephraimbuddy merged commit 7ea7fcd into apache:mainJul 8, 2025
193 of 194 checks passed
@ephraimbuddy
ephraimbuddy deleted the make-ti-dag-version-id-non-nullable2 branch July 8, 2025 17:55
HsiuChuanHsu pushed a commit to HsiuChuanHsu/airflow that referenced this pull request Jul 10, 2025
* Make dag_version_id in TI non-nullable
Enforces proper serialization of DAGs before creating DagRuns and TaskInstances.
The changes include:
- Making dag_version_id a required parameter in TaskInstance constructor
- Migrating the dag_version_id column in TaskInstance to be non-nullable
- Adding a check in _create_orm_dagrun to raise AirflowException if dag is not serialized
- Updating tests to ensure DAGs are properly serialized before creating DagRuns
This prevents running runs with missing serialized DAG versions.
* fixup! Make dag_version_id in TI non-nullable
* Fix tests for some providers
* fixup! Fix tests for some providers
* fixup! fixup! Fix tests for some providers
* more test fixes
* fixup! more test fixes
* fixup! fixup! more test fixes
* Update more tests
* fixup! Update more tests
* fixup! fixup! Update more tests
* fixup! fixup! fixup! Update more tests
* fixup! fixup! fixup! fixup! Update more tests
* fixup! fixup! fixup! fixup! fixup! Update more tests
* Add compat for MockedTaskInstance
* fixup! Add compat for MockedTaskInstance
* fixup! fixup! Add compat for MockedTaskInstance
* fix system test
* fixup! fix system test
* A fix for kube integration tests
* Update the expected TIs from test multiple versions number file
* fix incorrect imports
* fix time delta async test
* Remove non working kube test fix
* Fix task sdk test
* Add cadwyn migration and fix some tests
* fix some provider tests
* Add data migration before migrating dag_version_id
* Update test, TaskInstanceResponse and fix assert dag_version in task_command.py
* Resolve conflicts
* Fix test
* Fix more tests
* fixup! fixup! Fix more tests
* Fix bad rebase
* update fab www-hash
* Fix conflicts
* Fix MappedTaskInstancedata
* add dag_version_id to a new test
* Fix fab www hash
stephen-bracken pushed a commit to stephen-bracken/airflow that referenced this pull request Jul 15, 2025
* Make dag_version_id in TI non-nullable
Enforces proper serialization of DAGs before creating DagRuns and TaskInstances.
The changes include:
- Making dag_version_id a required parameter in TaskInstance constructor
- Migrating the dag_version_id column in TaskInstance to be non-nullable
- Adding a check in _create_orm_dagrun to raise AirflowException if dag is not serialized
- Updating tests to ensure DAGs are properly serialized before creating DagRuns
This prevents running runs with missing serialized DAG versions.
* fixup! Make dag_version_id in TI non-nullable
* Fix tests for some providers
* fixup! Fix tests for some providers
* fixup! fixup! Fix tests for some providers
* more test fixes
* fixup! more test fixes
* fixup! fixup! more test fixes
* Update more tests
* fixup! Update more tests
* fixup! fixup! Update more tests
* fixup! fixup! fixup! Update more tests
* fixup! fixup! fixup! fixup! Update more tests
* fixup! fixup! fixup! fixup! fixup! Update more tests
* Add compat for MockedTaskInstance
* fixup! Add compat for MockedTaskInstance
* fixup! fixup! Add compat for MockedTaskInstance
* fix system test
* fixup! fix system test
* A fix for kube integration tests
* Update the expected TIs from test multiple versions number file
* fix incorrect imports
* fix time delta async test
* Remove non working kube test fix
* Fix task sdk test
* Add cadwyn migration and fix some tests
* fix some provider tests
* Add data migration before migrating dag_version_id
* Update test, TaskInstanceResponse and fix assert dag_version in task_command.py
* Resolve conflicts
* Fix test
* Fix more tests
* fixup! fixup! Fix more tests
* Fix bad rebase
* update fab www-hash
* Fix conflicts
* Fix MappedTaskInstancedata
* add dag_version_id to a new test
* Fix fab www hash
Comment on lines +280 to +282
dag = DagBag().get_dag("test_mapped_classic")
dag.sync_to_db()
SerializedDagModel.write_dag(dag, bundle_name="testing")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has introduced a bug. This was the clue where we had to change the test

ephraimbuddy added a commit to astronomer/airflow that referenced this pull request Aug 11, 2025
This is alternative to apache#53820. Here we make the TI.dag_version_id
nullable on the database level. it's still enforced in code
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:APIAirflow's REST/HTTP APIarea:CLIarea:db-migrationsPRs with DB migrationarea:Schedulerincluding HA (high availability) schedulerarea:serializationarea:task-sdkarea:Triggererfull tests neededWe need to run full set of tests for this PR to mergekind:documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@ephraimbuddy@pierrejeambrun@uranusjr@kaxil@dstandish@jedcunningham@phanikumv