Skip to content

TriggerDagRunOperator is failing #49113

Closed

Description

@atuls4441

Apache Airflow version

3.0.0rc2

If "Other Airflow 2 version" selected, which one?

No response

What happened?

ERROR - Unable to decode message: line="{\"state\":\"success\"}\n": source="CommsDecoder"
ValidationError: 1 validation error for tagged-union[AssetResult,AssetEventsResult,ConnectionResult,DagRunStateResult,DRCount,ErrorResponse,PrevSuccessfulDagRunResult,StartupDetails,TaskRescheduleStartDate,TICount,VariableResult,XComResult,XComCountResponse,OKResponse]
  Unable to extract tag using discriminator 'type' [type=union_tag_not_found, input_value={'state': 'success'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.11/v/union_tag_not_found
File "/opt/airflow/task-sdk/src/airflow/sdk/execution_time/task_runner.py", line 582 in get_message

File "/usr/local/lib/python3.9/site-packages/pydantic/type_adapter.py", line 468 in validate_json

[2025-04-11, 10:19:57] ERROR - Top level error: source="task"
ValidationError: 1 validation error for tagged-union[AssetResult,AssetEventsResult,ConnectionResult,DagRunStateResult,DRCount,ErrorResponse,PrevSuccessfulDagRunResult,StartupDetails,TaskRescheduleStartDate,TICount,VariableResult,XComResult,XComCountResponse,OKResponse]
  Unable to extract tag using discriminator 'type' [type=union_tag_not_found, input_value={'state': 'success'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.11/v/union_tag_not_found
File "/opt/airflow/task-sdk/src/airflow/sdk/execution_time/task_runner.py", line 1167 in main

File "/opt/airflow/task-sdk/src/airflow/sdk/execution_time/task_runner.py", line 7[8](http://localhost:28080/dags/trigger_controller_dag/runs/manual__2025-04-11T10:18:56.774290+00:00/tasks/test_trigger_dagrun?try_number=1#8)6 in run

File "/opt/airflow/task-sdk/src/airflow/sdk/execution_time/task_runner.py", line 936 in _handle_trigger_dag_run

File "/opt/airflow/task-sdk/src/airflow/sdk/execution_time/task_runner.py", line 582 in get_message

File "/usr/local/lib/python3.9/site-packages/pydantic/type_adapter.py", line 468 in validate_json

What you think should happen instead?

No response

How to reproduce

Run the below Dag:

from airflow.sdk import DAG
from pendulum import today
from airflow.providers.standard.operators.trigger_dagrun import TriggerDagRunOperator

"""This example illustrates the use of the TriggerDagRunOperator. There are 2
entities at work in this scenario:
1. The Controller DAG - the DAG that conditionally executes the trigger
2. The Target DAG - DAG being triggered (in trigger_dagrun_target.py)

"""

dag = DAG(
    dag_id="trigger_controller_dag",
    default_args={"owner": "airflow", "start_date": today('UTC').add(days=-2)},
    schedule=None,
    tags=["core"],
)


trigger = TriggerDagRunOperator(
    task_id="test_trigger_dagrun",
    trigger_dag_id="trigger_target_dag",
    reset_dag_run=True,
    wait_for_completion=True,
    conf={"message": "Hello World"},
    dag=dag,
)
from airflow.sdk import DAG
from airflow.providers.standard.operators.bash import BashOperator
from airflow.providers.standard.operators.python import PythonOperator
from pendulum import today


dag = DAG(
    dag_id="trigger_target_dag",
    default_args={"start_date": today('UTC').add(days=-2), "owner": "Airflow"},
    tags=["core"],
    schedule=None,  # This must be none so it's triggered by the controller
    is_paused_upon_creation=False, # This must be set so other workers can pick this dag up. mabye it's a bug idk
)


def run_this_func(**context):
    print(
        f"Remotely received value of {context['dag_run'].conf['message']} for key=message "
    )


run_this = PythonOperator(
    task_id="run_this",
    python_callable=run_this_func,
    dag=dag,
)

# You can also access the DagRun object in templates
bash_task = BashOperator(
    task_id="bash_task",
    bash_command='echo "Here is the message: $message"',
    env={"message": '{{ dag_run.conf["message"] if dag_run else "" }}'},
    dag=dag,
)

Operating System

Linux

Versions of Apache Airflow Providers

No response

Deployment

Other

Deployment details

No response

Anything else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Activity

  1. added
    priority:highHigh priority bug that should be patched quickly but does not require immediate new release
    and removed
    needs-triagelabel for new issues that we didn't triage yet
    on Apr 11, 2025
  2. tirkarthi commented on Apr 11, 2025

    @tirkarthi
    Contributor
  3. tirkarthi commented on Apr 11, 2025

    @tirkarthi
    Contributor

    I saw this too morning but this was only in deferrable mode. Does it happen during normal mode too?

  4. gopidesupavan commented on Apr 11, 2025

    @gopidesupavan
    Member

    hey yes i noticed this already yesterday, this side effect of one of the pr. i have raised change #49095

  5. gopidesupavan commented on Apr 11, 2025

    @gopidesupavan
    Member

    I saw this too morning but this was only in deferrable mode. Does it happen during normal mode too?

    This happens for both modes

  6. gopidesupavan commented on Apr 11, 2025

    @gopidesupavan
    Member

    Just seen one more issue, GeTICount response conversion also failing. updated PR to include both changes

  7. gopidesupavan commented on Apr 11, 2025

    @gopidesupavan
    Member

    fixed here #49095

  8. gopidesupavan commented on Apr 11, 2025

    @gopidesupavan
    Member

    @atul-astronomer this is merged could you please check on main, i have closed this, if not working we can reopen :)

  9. atuls4441 commented on Apr 11, 2025

    @atuls4441
    ContributorAuthor

    Working fine now on main latest.

  10. added this to the Airflow 3.0.0 milestone on Apr 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:corekind:bugThis is a clearly a bugpriority:highHigh priority bug that should be patched quickly but does not require immediate new release

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions