Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix triggerer errors after Airflow 2 to 3 migration#55884

Merged
ephraimbuddy merged 4 commits intoapache:mainfrom
astronomer:fix-failing-triggers-after-migration
Oct 22, 2025
Merged

Fix triggerer errors after Airflow 2 to 3 migration#55884
ephraimbuddy merged 4 commits intoapache:mainfrom
astronomer:fix-failing-triggers-after-migration

Conversation

Copy link
Contributor

ephraimbuddy commented Sep 19, 2025 *
edited
Loading

When upgrading from Airflow 2, existing deferred triggers can reference TaskInstances without a dag_version_id and DagRuns with conf=None. This caused errors when the triggerer tried to start those triggers and when workers consumed ti_run responses.

This change:

  1. Skips starting triggers whose TaskInstance lacks dag_version_id, logging a warning instead of erroring
  2. Coerces DagRun.conf from None to {} in the ti_run response for compatibility with Airflow 2-era data
  3. Adds unit tests covering both behaviors

This prevents triggerer crashes and makes deferred tasks resume reliably after migration.

closes: #55713

How to test:

set a fernet key e.g:
export AIRFLOW__CORE__FERNET_KEY='8janSoQD86ALy_tnJjR-hcxNweHnUxhfDV61TBntr_4='
in both init.sh and environment_variables.env in airflow source.
AF2 uses init.sh for breeze but environment_variables.env is used in AF3.

Switch to airflow 2: git switch apache/v2-11-stable
Add this dag with the target time adjusted to maybe 30mins in the future:

from datetime import datetime
from airflow import DAG

from airflow.sensors.date_time import DateTimeSensorAsync


with (DAG("async_trigger_sleep", start_date=datetime(2025,9,17),tags=["async_migration"])
) as dag:
DateTimeSensorAsync(
task_id="wait_for_start",
target_time=datetime(2025, 9, 19, 11, 26),

)

start breeze breeze start-airflow --backend postgres --executor CeleryExecutor
Trigger the dag above and stop breeze once the task is deferred.
Switch to Airflow 3: git switch main
Start breeze: breeze start-airflow --backend postgres --executor CeleryExecutor

See that when the target time reach, the dag would be successful

pdellarciprete and phanikumv reacted with thumbs up emoji
ephraimbuddy requested review from amoghrajesh, ashb, dstandish, hussein-awala and kaxil as code owners September 19, 2025 11:49
boring-cyborg bot added area:API Airflow's REST/HTTP API area:Triggerer labels Sep 19, 2025
ephraimbuddy mentioned this pull request Sep 19, 2025
ashb reviewed Sep 19, 2025
kaxil added this to the Airflow 3.1.1 milestone Sep 19, 2025
Copy link

pdellarciprete commented Sep 29, 2025

We are having exactly the same issue, and it is causing the crash of the scheduler. Any plan to release it soon?
Is there any workaround to fix the values on the databases?

Giuzzilla reacted with thumbs up emoji

kaxil modified the milestones: Airflow 3.1.1, Airflow 3.1.2 Oct 21, 2025
ephraimbuddy force-pushed the fix-failing-triggers-after-migration branch from 45b6da9 to 9047086 Compare October 22, 2025 11:42
ashb approved these changes Oct 22, 2025
ephraimbuddy force-pushed the fix-failing-triggers-after-migration branch from 9047086 to 43bca86 Compare October 22, 2025 17:08
ephraimbuddy added 4 commits October 22, 2025 20:19
When upgrading from Airflow 2, existing deferred triggers can reference
TaskInstances without a dag_version_id and DagRuns with conf=None. This
caused errors when the triggerer tried to start those triggers and when
workers consumed ti_run responses.

This change:
1. Skips starting triggers whose TaskInstance lacks dag_version_id, logging
a warning instead of erroring
2. Coerces DagRun.conf from None to {} in the ti_run response for
compatibility with Airflow 2-era data
3. Adds unit tests covering both behaviors

This prevents triggerer crashes and makes deferred tasks resume reliably
after migration.
ephraimbuddy force-pushed the fix-failing-triggers-after-migration branch from 43bca86 to fef8897 Compare October 22, 2025 19:19
ephraimbuddy merged commit 7cec2a7 into apache:main Oct 22, 2025
60 checks passed
ephraimbuddy deleted the fix-failing-triggers-after-migration branch October 22, 2025 22:23
kaxil pushed a commit that referenced this pull request Oct 31, 2025
* Fix triggerer errors after Airflow 2 to 3 migration

When upgrading from Airflow 2, existing deferred triggers can reference
TaskInstances without a dag_version_id and DagRuns with conf=None. This
caused errors when the triggerer tried to start those triggers and when
workers consumed ti_run responses.

This change:
1. Skips starting triggers whose TaskInstance lacks dag_version_id, logging
a warning instead of erroring
2. Coerces DagRun.conf from None to {} in the ti_run response for
compatibility with Airflow 2-era data
3. Adds unit tests covering both behaviors

This prevents triggerer crashes and makes deferred tasks resume reliably
after migration.

* Remove config check as that has been addressed in a different PR

* Add comment on why we added this

* Remove null conf test

(cherry picked from commit 7cec2a7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

ashb ashb approved these changes

dstandish Awaiting requested review from dstandish dstandish is a code owner

hussein-awala Awaiting requested review from hussein-awala hussein-awala is a code owner

kaxil Awaiting requested review from kaxil

amoghrajesh Awaiting requested review from amoghrajesh

Assignees

No one assigned

Labels

area:API Airflow's REST/HTTP API area:Triggerer

Projects

None yet

Milestone

Airflow 3.1.2

Development

Successfully merging this pull request may close these issues.

Triggerer crash when migrating Airflow 2 to 3 with async dagrun already in deferred state

4 participants