Skip to content

Slack notifications stopped working after upgrade to 3.0.1 #50754

Closed as not planned

Description

@arturzangiev

Apache Airflow version

3.0.1

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

No response

What happened?

Slack notifications stopped working after upgrade to 3.0.1

What you think should happen instead?

Should send a slack notification to the channel

How to reproduce

with DAG(
    dag_id='name',
    default_args=default_args,
    description='description',
    schedule=None,
    start_date=datetime.now() - timedelta(days=365),
    catchup=False,
    max_active_runs=1,
    on_failure_callback=[
        send_slack_webhook_notification(
            slack_webhook_conn_id="slackwebhook", 
            text="The dag `{{ dag.dag_id }}` failed"
        )
    ]
) as dag:

    def fail_task():
        raise ValueError("This task fails on purpose.")

    task1 = PythonOperator(
        task_id='fail_task',
        python_callable=fail_task
    )

Operating System

debian

Versions of Apache Airflow Providers

apache-airflow-providers-slack 9.0.5

Deployment

Docker-Compose

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
    kind:bug
    needs-triage
    on May 18, 2025
  2. boring-cyborg commented on May 18, 2025

    @boring-cyborg

    Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.

  3. amoghrajesh commented on May 19, 2025

    @amoghrajesh
    Contributor

    @arturzangiev what errors do you see in your tasks or in the scheduler / worker?

  4. arturzangiev commented on May 19, 2025

    @arturzangiev
    Author

    It is strange, but i can't find any slack related logs in my tasks or scheduler

  5. uranusjr commented on May 20, 2025

    @uranusjr
    Member

    What version were you upgrading from?

  6. uranusjr commented on May 20, 2025

    @uranusjr
    Member

    Does the dag processor process contain logs about callbacks?

  7. arturzangiev commented on May 20, 2025

    @arturzangiev
    Author

    I have upgraded from airflow:2.10.2 to airflow:3.0.1. I checked processor logs and can't find anything around callbacks.

  8. niklasr22 commented on May 20, 2025

    @niklasr22
    Contributor

    I have the same problem (Upgraded from 2.10.5 to 3.0.1, running in Docker). I also can't find any callback/slack provider specific logs.

  9. added
    affected_version:3.0
    on May 21, 2025
  10. niklasr22 commented on May 22, 2025

    @niklasr22
    Contributor

    I think none of the callbacks (not slack specific) that rely on having a context work. Maybe I'm understanding something wrong but in the dag processor, it looks like the context passed to the callbacks is always empty. (The TODO indicates some missing stuff as well)

    # TODO:We need a proper context object!
    context: Context = {} # type: ignore[assignment]
    for callback in callbacks:
    log.info(
    "Executing on_%s dag callback",
    "failure" if request.is_failure_callback else "success",
    dag_id=request.dag_id,
    )
    try:
    callback(context)

    I also found a log:

    {"timestamp":"2025-05-22T08:39:02.769046","level":"error","event":"Callback failed","dag_id":"cb_test_dag","logger":"task","error_detail":[{"exc_type":"KeyError","exc_value":"'dag'","exc_notes":[],"syntax_error":null,"is_cause":false,"frames":[{"filename":"/Users/x/airflow-installation/.venv/lib/python3.12/site-packages/airflow/dag_processing/processor.py","lineno":213,"name":"_execute_dag_callbacks"},{"filename":"/Users/x/airflow-installation/.venv/lib/python3.12/site-packages/airflow/sdk/bases/notifier.py","lineno":103,"name":"__call__"},{"filename":"/Users/x/airflow-installation/.venv/lib/python3.12/site-packages/airflow/sdk/bases/notifier.py","lineno":72,"name":"render_template_fields"}]}]}
    
  11. uranusjr commented on May 22, 2025

    @uranusjr
    Member

    Do either you see the Executing on_%s dag callback log?

  12. niklasr22 commented on May 22, 2025

    @niklasr22
    Contributor

    Yes:

    {"timestamp":"2025-05-22T08:58:02.638108","level":"info","event":"Executing on_success dag callback","dag_id":"cb_test_dag","logger":"task"}
    {"timestamp":"2025-05-22T08:58:02.638127","level":"error","event":"Callback failed","dag_id":"cb_test_dag","logger":"task","error_detail":[{"exc_type":"KeyError","exc_value":"'dag'","exc_notes":[],"syntax_error":null,"is_cause":false,"frames":[{"filename":"/Users/x/airflow-installation/.venv/lib/python3.12/site-packages/airflow/dag_processing/processor.py","lineno":213,"name":"_execute_dag_callbacks"},{"filename":"/Users/x/airflow-installation/.venv/lib/python3.12/site-packages/airflow/sdk/bases/notifier.py","lineno":103,"name":"__call__"},{"filename":"/Users/x/airflow-installation/.venv/lib/python3.12/site-packages/airflow/sdk/bases/notifier.py","lineno":72,"name":"render_template_fields"}]}]}
    
  13. 2 remaining items

  14. added
    area:task-execution-interface-aip72
    and removed
    needs-triage
    on May 22, 2025
  15. uranusjr commented on May 22, 2025

    @uranusjr
    Member

    Are context variables dag run_id reason enough for your use cases? I’ll close this one if so. List what you need otherwise and we’ll work on adding them.

  16. htamakos commented on May 23, 2025

    @htamakos

    I have encountered the same issue.

    Environment:

    Airflow 3.0.1 on Kubernetes

    Observed behavior:

    • DAG-level on_success_callback and on_failure_callback do not work (no error logs or other output observed).
    • Task-level on_success_callback, on_failure_callback, and on_execute_callback do work as expected.
  17. niklasr22 commented on May 23, 2025

    @niklasr22
    Contributor

    Currently for my use case those will be sufficient, but maybe this should be noted somewhere in the docs or in a new issue as it isn't obvious that most context vars won't work and cause a silent failure (for people who can't access all logs but only the UI).

  18. github-actions commented on Jun 7, 2025

    @github-actions
    Contributor

    This issue has been automatically marked as stale because it has been open for 14 days with no response from the author. It will be closed in next 7 days if no further activity occurs from the issue author.

  19. added
    stale
    on Jun 7, 2025
  20. github-actions commented on Jun 15, 2025

    @github-actions
    Contributor

    This issue has been closed because it has not received response from the issue author.

  21. Nevioxis commented on Jun 30, 2025

    @Nevioxis

    I've upgraded from 2.10.5 to 3.0.2 and my Slack notification also broken. After debugging, I found out that task_instance variable will send None to task_instance.end_date and not send task_instance.duration if task stated as failed. So, if your notification contains end_date and duration for failed DAG, just remove it or find a new way to handle it will make notification back.

  22. amoghrajesh commented on Jul 1, 2025

    @amoghrajesh
    Contributor

    @Nevioxis could you point at some things and if possible raise an appropriate issue? We will take a look.

  23. Nevioxis commented on Jul 1, 2025

    @Nevioxis

    @amoghrajesh I've opened new issue.

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

    affected_version:3.0area:task-execution-interface-aip72area:task-sdkkind:bugpending-responsestale

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions