Skip to content

RuntimeTaskInstance object' has no attribute 'mark_success_url' #53135

Closed

Description

@MohamedEqinov

Apache Airflow version

3.0.2

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

No response

What happened?

When using Airflow 3.x with email_on_failure=True in task configuration, email notifications fail to send due to template rendering errors in the default email templates. This issue appears to be an ongoing regression in the new SDK architecture.

Issue Evolution:

1. Airflow 3.0.1 - log_url Template Error:

UndefinedError: 'airflow.sdk.execution_time.task_runner.RuntimeTaskInstance object' has no attribute 'log_url'

File "/home/airflow/.local/lib/python3.12/site-packages/airflow/sdk/execution_time/task_runner.py", line 1268 in main
File "/home/airflow/.local/lib/python3.12/site-packages/airflow/sdk/execution_time/task_runner.py", line 1248 in finalize
File "/home/airflow/.local/lib/python3.12/site-packages/airflow/sdk/execution_time/task_runner.py", line 1076 in _send_task_error_email
File "/home/airflow/.local/lib/python3.12/site-packages/airflow/models/taskinstance.py", line 473 in _get_email_subject_content
File "/home/airflow/.local/lib/python3.12/site-packages/airflow/utils/helpers.py", line 244 in render_template_to_string
File "<template>", line 22 in root

2. Airflow 3.0.3rc5 - mark_success_url Template Error: After upgrading to 3.0.3rc5 expecting the template issue to be resolved, a different but similar error occurred:

UndefinedError: 'airflow.sdk.execution_time.task_runner.RuntimeTaskInstance object' has no attribute 'mark_success_url'

File "/home/airflow/.local/lib/python3.12/site-packages/airflow/sdk/execution_time/task_runner.py", line 1302 in main
File "/home/airflow/.local/lib/python3.12/site-packages/airflow/sdk/execution_time/task_runner.py", line 1279 in finalize
File "/home/airflow/.local/lib/python3.12/site-packages/airflow/sdk/execution_time/task_runner.py", line 1110 in _send_task_error_email
File "/home/airflow/.local/lib/python3.12/site-packages/airflow/models/taskinstance.py", line 411 in _get_email_subject_content
File "/home/airflow/.local/lib/python3.12/site-packages/airflow/utils/helpers.py", line 244 in render_template_to_string
File "<template>", line 26 in root

Root Cause: The default email templates reference template variables ({{ log_url }}, {{ mark_success_url }}) that are not available in the new SDK's RuntimeTaskInstance object. While the log_url issue has been addressed between 3.0.1 and 3.0.3rc5, the mark_success_url template variable still causes the same type of rendering failure.

Impact: Email notifications for task failures remain completely broken when using default email templates across multiple Airflow 3.x versions, preventing critical alerting functionality.

What you think should happen instead?

Expected Behavior: When a task fails and email_on_failure=True is configured, Airflow should successfully send email notifications using the default email templates without any template rendering errors. The email notification system should work seamlessly regardless of whether the task is running under the legacy execution model or the new SDK architecture.

Specifically:

Tasks with email_on_failure=True should trigger email notifications on failure
Default email templates should render successfully with all required template variables
Email notifications should be sent via the configured SMTP connection
Users should receive informative failure notification emails containing relevant task and execution details

Root Cause Analysis:

Incomplete SDK Migration: The new SDK architecture introduced RuntimeTaskInstance objects that have a different structure/interface compared to the legacy TaskInstance objects, but the default email templates were not fully updated to accommodate this change.

Template Variable Mapping: The default email templates still reference template variables (log_url, mark_success_url) that were available in the legacy task instance model but are either missing, renamed, or structured differently in the new RuntimeTaskInstance object.

Incremental Fix Approach: The fix appears to be incomplete - while log_url was addressed between 3.0.1 and 3.0.3rc5, mark_success_url still causes the same issue.

Missing Template Context Adaptation: The email rendering system may need an adapter layer to bridge the gap between the new SDK objects and the existing template variables, or the templates need to be completely rewritten to use the correct attribute paths for the new object structure.

Suggested Solution: Either update all default email templates to use template variables that are available in RuntimeTaskInstance, or provide a compatibility layer that maps the legacy template variables to their new equivalents in the SDK architecture.

How to reproduce

Minimal Reproduction Case:

  1. Setup Airflow 3.0.1 or 3.0.3rc5 (using Docker or any installation method)
  2. Configure SMTP connection via Airflow UI:
  • Go to Admin → Connections
  • Create a new connection with Connection Id: smtp_default (as referenced in the default config)
  • Set Connection Type: SMTP
  • Configure your SMTP server details (host, port, login, password)
  • Note: This approach uses the UI instead of modifying airflow.cfg since the default config references email_conn_id = smtp_default
  1. Create a simple DAG that will fail with email notifications enabled:
from airflow import DAG
from airflow.operators.bash import BashOperator
from datetime import datetime, timedelta

default_args = {
    "owner": "test",
    "email_on_failure": True,
    "email": ["[email protected]"],
    "retries": 0,  # No retries to fail immediately
}

with DAG(
    dag_id="test_email_failure",
    default_args=default_args,
    description="Test email failure notifications",
    schedule=None,  # Manual trigger only
    start_date=datetime(2024, 1, 1),
    catchup=False,
) as dag:

    # Task that will always fail
    failing_task = BashOperator(
        task_id="failing_task",
        bash_command="exit 1",  # Force failure
    )
  1. Trigger the DAG manually from the Airflow UI or CLI
  2. Observe the failure: : The task will fail as expected, but instead of sending an email notification, you'll see template rendering errors in the task logs.

Expected Result: Email notification should be sent successfully using the smtp_default connection.

Actual Result:

In Airflow 3.0.1: UndefinedError: 'RuntimeTaskInstance object' has no attribute 'log_url'
In Airflow 3.0.3rc5: UndefinedError: 'RuntimeTaskInstance object' has no attribute 'mark_success_url'

Operating System

NAME="Ubuntu" VERSION="20.04.6 LTS (Focal Fossa)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 20.04.6 LTS" VERSION_ID="20.04" HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" VERSION_CODENAME=focal UBUNTU_CODENAME=focal

Versions of Apache Airflow Providers

apache-airflow-providers-amazon | 9.9.0 | Amazon integration (including Amazon Web Services (AWS) https://aws.amazon.com/) -- | -- | -- apache-airflow-providers-celery | 3.12.1 | Celery https://docs.celeryq.dev/en/stable/ apache-airflow-providers-cncf-kubernetes | 10.6.1 | Kubernetes https://kubernetes.io/ apache-airflow-providers-common-compat | 1.7.2 | Common Compatibility Provider - providing compatibility code for previous Airflow versions apache-airflow-providers-common-io | 1.6.1 | Common IO Provider apache-airflow-providers-common-messaging | 1.0.4 | Common Messaging Provider apache-airflow-providers-common-sql | 1.27.3 | Common SQL Provider https://en.wikipedia.org/wiki/SQL apache-airflow-providers-docker | 4.4.1 | Docker https://www.docker.com/ apache-airflow-providers-elasticsearch | 6.3.1 | Elasticsearch https://www.elastic.co/elasticsearch apache-airflow-providers-fab | 2.3.0 | Flask App Builder https://flask-appbuilder.readthedocs.io/ apache-airflow-providers-ftp | 3.13.1 | File Transfer Protocol (FTP) https://tools.ietf.org/html/rfc114 apache-airflow-providers-git | 0.0.4 | Distributed version control system (GIT) https://git-scm.com/ apache-airflow-providers-google | 16.1.0 | Google services including: - Google Ads https://ads.google.com/ - Google Cloud (GCP) https://cloud.google.com/ - Google Firebase https://firebase.google.com/ - Google LevelDB https://github.com/google/leveldb/ - Google Marketing Platform https://marketingplatform.google.com/ - Google Workspace https://workspace.google.com/(formerly Google Suite) apache-airflow-providers-grpc | 3.8.1 | gRPC https://grpc.io/ apache-airflow-providers-hashicorp | 4.3.1 | Hashicorp including Hashicorp Vault https://www.vaultproject.io/ apache-airflow-providers-http | 5.3.2 | Hypertext Transfer Protocol (HTTP) https://www.w3.org/Protocols/ apache-airflow-providers-microsoft-azure | 12.5.0 | Microsoft Azure https://azure.microsoft.com/ apache-airflow-providers-mysql | 6.3.2 | MySQL https://www.mysql.com/ apache-airflow-providers-odbc | 4.10.1 | ODBC https://github.com/mkleehammer/pyodbc/wiki apache-airflow-providers-openlineage | 2.5.0 | OpenLineage https://openlineage.io/ apache-airflow-providers-postgres | 6.2.1 | PostgreSQL https://www.postgresql.org/ apache-airflow-providers-redis | 4.1.1 | Redis https://redis.io/ apache-airflow-providers-sendgrid | 4.1.2 | Sendgrid https://sendgrid.com/ apache-airflow-providers-sftp | 5.3.2 | SSH File Transfer Protocol (SFTP) https://tools.ietf.org/wg/secsh/draft-ietf-secsh-filexfer/ apache-airflow-providers-slack | 9.1.2 | Slack https://slack.com/services integration including: - Slack API https://api.slack.com/ - Slack Incoming Webhook https://api.slack.com/messaging/webhooks apache-airflow-providers-smtp | 2.1.1 | Simple Mail Transfer Protocol (SMTP) https://tools.ietf.org/html/rfc5321 apache-airflow-providers-snowflake | 6.5.0 | Snowflake https://www.snowflake.com/ apache-airflow-providers-ssh | 4.1.1 | Secure Shell (SSH) https://tools.ietf.org/html/rfc4251 apache-airflow-providers-standard | 1.4.0 | Airflow Standard Provider [apache-airflow-providers-amazon](https://airflow.apache.org/docs/apache-airflow-providers-amazon/9.9.0/) 9.9.0 Amazon integration (including Amazon Web Services (AWS) https://aws.amazon.com/) [apache-airflow-providers-celery](https://airflow.apache.org/docs/apache-airflow-providers-celery/3.12.1/) 3.12.1 Celery https://docs.celeryq.dev/en/stable/ [apache-airflow-providers-cncf-kubernetes](https://airflow.apache.org/docs/apache-airflow-providers-cncf-kubernetes/10.6.1/) 10.6.1 Kubernetes https://kubernetes.io/ [apache-airflow-providers-common-compat](https://airflow.apache.org/docs/apache-airflow-providers-common-compat/1.7.2/) 1.7.2 Common Compatibility Provider - providing compatibility code for previous Airflow versions [apache-airflow-providers-common-io](https://airflow.apache.org/docs/apache-airflow-providers-common-io/1.6.1/) 1.6.1 Common IO Provider [apache-airflow-providers-common-messaging](https://airflow.apache.org/docs/apache-airflow-providers-common-messaging/1.0.4/) 1.0.4 Common Messaging Provider [apache-airflow-providers-common-sql](https://airflow.apache.org/docs/apache-airflow-providers-common-sql/1.27.3/) 1.27.3 Common SQL Provider https://en.wikipedia.org/wiki/SQL [apache-airflow-providers-docker](https://airflow.apache.org/docs/apache-airflow-providers-docker/4.4.1/) 4.4.1 Docker https://www.docker.com/ [apache-airflow-providers-elasticsearch](https://airflow.apache.org/docs/apache-airflow-providers-elasticsearch/6.3.1/) 6.3.1 Elasticsearch https://www.elastic.co/elasticsearch [apache-airflow-providers-fab](https://airflow.apache.org/docs/apache-airflow-providers-fab/2.3.0/) 2.3.0 Flask App Builder https://flask-appbuilder.readthedocs.io/ [apache-airflow-providers-ftp](https://airflow.apache.org/docs/apache-airflow-providers-ftp/3.13.1/) 3.13.1 File Transfer Protocol (FTP) https://tools.ietf.org/html/rfc114 [apache-airflow-providers-git](https://airflow.apache.org/docs/apache-airflow-providers-git/0.0.4/) 0.0.4 Distributed version control system (GIT) https://git-scm.com/ [apache-airflow-providers-google](https://airflow.apache.org/docs/apache-airflow-providers-google/16.1.0/) 16.1.0 Google services including: - Google Ads https://ads.google.com/ - Google Cloud (GCP) https://cloud.google.com/ - Google Firebase https://firebase.google.com/ - Google LevelDB https://github.com/google/leveldb/ - Google Marketing Platform https://marketingplatform.google.com/ - Google Workspace https://workspace.google.com/(formerly Google Suite) [apache-airflow-providers-grpc](https://airflow.apache.org/docs/apache-airflow-providers-grpc/3.8.1/) 3.8.1 gRPC https://grpc.io/ [apache-airflow-providers-hashicorp](https://airflow.apache.org/docs/apache-airflow-providers-hashicorp/4.3.1/) 4.3.1 Hashicorp including Hashicorp Vault https://www.vaultproject.io/ [apache-airflow-providers-http](https://airflow.apache.org/docs/apache-airflow-providers-http/5.3.2/) 5.3.2 Hypertext Transfer Protocol (HTTP) https://www.w3.org/Protocols/ [apache-airflow-providers-microsoft-azure](https://airflow.apache.org/docs/apache-airflow-providers-microsoft-azure/12.5.0/) 12.5.0 Microsoft Azure https://azure.microsoft.com/ [apache-airflow-providers-mysql](https://airflow.apache.org/docs/apache-airflow-providers-mysql/6.3.2/) 6.3.2 MySQL https://www.mysql.com/ [apache-airflow-providers-odbc](https://airflow.apache.org/docs/apache-airflow-providers-odbc/4.10.1/) 4.10.1 ODBC https://github.com/mkleehammer/pyodbc/wiki [apache-airflow-providers-openlineage](https://airflow.apache.org/docs/apache-airflow-providers-openlineage/2.5.0/) 2.5.0 OpenLineage https://openlineage.io/ [apache-airflow-providers-postgres](https://airflow.apache.org/docs/apache-airflow-providers-postgres/6.2.1/) 6.2.1 PostgreSQL https://www.postgresql.org/ [apache-airflow-providers-redis](https://airflow.apache.org/docs/apache-airflow-providers-redis/4.1.1/) 4.1.1 Redis https://redis.io/ [apache-airflow-providers-sendgrid](https://airflow.apache.org/docs/apache-airflow-providers-sendgrid/4.1.2/) 4.1.2 Sendgrid https://sendgrid.com/ [apache-airflow-providers-sftp](https://airflow.apache.org/docs/apache-airflow-providers-sftp/5.3.2/) 5.3.2 SSH File Transfer Protocol (SFTP) https://tools.ietf.org/wg/secsh/draft-ietf-secsh-filexfer/ [apache-airflow-providers-slack](https://airflow.apache.org/docs/apache-airflow-providers-slack/9.1.2/) 9.1.2 Slack https://slack.com/services integration including: - Slack API https://api.slack.com/ - Slack Incoming Webhook https://api.slack.com/messaging/webhooks [apache-airflow-providers-smtp](https://airflow.apache.org/docs/apache-airflow-providers-smtp/2.1.1/) 2.1.1 Simple Mail Transfer Protocol (SMTP) https://tools.ietf.org/html/rfc5321 [apache-airflow-providers-snowflake](https://airflow.apache.org/docs/apache-airflow-providers-snowflake/6.5.0/) 6.5.0 Snowflake https://www.snowflake.com/ [apache-airflow-providers-ssh](https://airflow.apache.org/docs/apache-airflow-providers-ssh/4.1.1/) 4.1.1 Secure Shell (SSH) https://tools.ietf.org/html/rfc4251 [apache-airflow-providers-standard](https://airflow.apache.org/docs/apache-airflow-providers-standard/1.4.0/) 1.4.0 Airflow Standard Provider

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 Jul 10, 2025
  2. boring-cyborg commented on Jul 10, 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. eladkal commented on Jul 12, 2025

    @eladkal
    Contributor

    email_on_failure and email are deprecated in Airflow 3 and will be removed in Airflow 4.

    if email and email_on_retry is not None:
    warnings.warn(
    "Setting email_on_retry on a task is deprecated; please migrate to SmtpNotifier.",
    RemovedInAirflow4Warning,
    stacklevel=2,
    )
    if email and email_on_failure is not None:
    warnings.warn(
    "Setting email_on_failure on a task is deprecated; please migrate to SmtpNotifier.",
    RemovedInAirflow4Warning,
    stacklevel=2,
    )

    can you please try to use SmtpNotifier and let us know if it solves the problem?
    regardless it should work but migrating to SmtpNotifier can resolve your issue till we fix the underlying cause

  4. added
    area:task-execution-interface-aip72
    affected_version:3.0
    and removed
    needs-triage
    on Jul 12, 2025
  5. gbonazzoli commented on Aug 3, 2025

    @gbonazzoli

    @eladkal

    In Airflow 3.0.3 the problem arises also using SmtpNotifier:

    email_notifier = SmtpNotifier(to=['[email protected]'])
    
    default_args = {
        'owner': 'gbonazzoli',
        'retries': 0,
        'start_date' : datetime(2023, 7, 1, 0, 0),
        'catchup' : False,  # The catchup defines if the DAG should run for every interval from it’s start time until the current time or not
        'on_failure_callback': [email_notifier],
    }

    I can force the error with a BashOperator pointing to a non existing path (/usr/bin/javaZZ):

        Show_Java_Version = BashOperator(
            task_id = 'Show_Java_Version',
            bash_command = '/usr/bin/javaZZ --version'
        )

    and the log is:

    [2025-08-03, 05:27:20] INFO - Connection Retrieved 'smtp_default': source="airflow.hooks.base"
    [2025-08-03, 05:27:20] ERROR - Failed to send notification: 'airflow.sdk.execution_time.task_runner.RuntimeTaskInstance object' has no attribute 'mark_success_url': source="airflow.providers.smtp.notifications.smtp.SmtpNotifier"
    UndefinedError: 'airflow.sdk.execution_time.task_runner.RuntimeTaskInstance object' has no attribute 'mark_success_url'
    File "/root/venv/lib/python3.12/site-packages/airflow/sdk/bases/notifier.py", line 105 in __call__
    File "/root/venv/lib/python3.12/site-packages/airflow/providers/smtp/notifications/smtp.py", line 139 in notify
    File "/root/venv/lib/python3.12/site-packages/airflow/sdk/definitions/_internal/templater.py", line 121 in _do_render_template_fields
    File "/root/venv/lib/python3.12/site-packages/airflow/sdk/definitions/_internal/templater.py", line 177 in render_template
    File "/root/venv/lib/python3.12/site-packages/airflow/sdk/bases/notifier.py", line 57 in _render
    File "/root/venv/lib/python3.12/site-packages/airflow/sdk/definitions/_internal/templater.py", line 133 in _render
    File "/root/venv/lib/python3.12/site-packages/airflow/utils/helpers.py", line 244 in render_template_to_string
    File "/root/venv/lib/python3.12/site-packages/airflow/utils/helpers.py", line 239 in render_template
    File "<template>", line 41 in root
    File "/root/venv/lib/python3.12/site-packages/jinja2/runtime.py", line 859 in _fail_with_undefined_error
    

    The problem remains also if you try to force in airflow.cfg the use of custom templates with:

    subject_template = /root/airflow/airflow.cfg.subject_template
    html_content_template = /root/airflow/airflow.cfg.html_content_template
  6. gbonazzoli commented on Aug 3, 2025

    @gbonazzoli

    In Airflow 3.0.3, as work around, you can use the following recipe.

    Go to the root of the airflow installed package, in my installation is:

    cd /root/venv/lib/python3.12/site-packages/airflow

    and edit the default html email template with:

    vi ./providers/smtp/notifications/templates/email.html

    and delete the lines that refer to mark_success_url.

    By the way in Airflow 3.0.3 the configuration written down in airflow.cfg regarding custom email template is completely ignored (see my previous post on this #53135).

  7. dshvedchenko commented on Aug 11, 2025

    @dshvedchenko

    or copy default templates to inlcude and refer to them from

    Image
  8. gbonazzoli commented on Aug 12, 2025

    @gbonazzoli

    In Airflow 3.0.4 with SmtpNotifier and the configuration written down to smtp_default (in the Extra Fields), it works !!!

    Image

    I do not know if it works also in previous versions.

  9. ersalil commented on Aug 12, 2025

    @ersalil
    Contributor

    I was able to work around the issue by overriding the default template in SmtpNotifier and providing a custom html_content.

    Here’s an example snippet you can add to your DAG:

    # Custom SMTP notifier
    failure_notifier = SmtpNotifier(
        to=["[email protected]"],
        subject="Airflow Task Failed: {{ ti.task_id }} in DAG {{ ti.dag_id }}",
        html_content="""
            <h3>Airflow Task Failure</h3>
            <p><b>DAG:</b> {{ ti.dag_id }}</p>
            <p><b>Task:</b> {{ ti.task_id }}</p>
            <p><b>Execution Date:</b> {{ ts }}</p>
            <p><b>Log URL:</b> <a href="{{ ti.log_url }}">{{ ti.log_url }}</a></p>
        """
    )
    

    Use the notifier in default_args

    default_args = {
        "on_failure_callback": failure_notifier,
    }
    
  10. zachliu commented on Sep 12, 2025

    @zachliu
    Contributor

    just a heads-up, this fix is in apache-airflow-providers-smtp==2.2.1 yet the airflow 3.0.6 constraints still uses 2.2.0 😿

  11. eladkal commented on Sep 12, 2025

    @eladkal
    Contributor

    just a heads-up, this fix is in apache-airflow-providers-smtp==2.2.1 yet the airflow 3.0.6 constraints still uses 2.2.0 😿

    Constraints are fixed at release time and almost never change.
    You can generate your own constraints file. It's pretty easy.

  12. zachliu commented on Sep 16, 2025

    @zachliu
    Contributor

    just a heads-up, this fix is in apache-airflow-providers-smtp==2.2.1 yet the airflow 3.0.6 constraints still uses 2.2.0 😿

    Constraints are fixed at release time and almost never change. You can generate your own constraints file. It's pretty easy.

    that's okay though. what's more interesting is i didn't realize mark_success_url is the same as log_url...
    glad we just deprecated the former 🚀

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:corearea:task-execution-interface-aip72kind:bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions