airflow: Bug Report: Incorrect Log URL in Airflow 2.10.4

Apache Airflow version

2.10.4

If “Other Airflow 2 version” selected, which one?

No response

What happened?

Apache Airflow Version: 2.10.4 Previous Version (Worked as Expected): 2.9.3 Environment: Provide relevant details (e.g., deployment method, OS, executor type)

Description After upgrading Airflow from 2.9.3 to 2.10.4, I observed that the log_url function is generating incorrect URLs. The returned URL does not match the log view page URL in the UI. I am using Slack notifications; it was working fine until yesterday, but now the log URL redirects to the wrong URL path. using : “url”: task_instance.log_url.replace(“localhost:8080”, “prod.host.com”) airflow.models.taskinstance.TaskInstance => @property def log_url(self) -> str

incorrect: https://host/dags/dag_id/grid?dag_run_id=manual__2025-02-07T03%3A25%3A19.637151%2B00%3A00&task_id=xyz&base_date=2025-02-07T03%3A25%3A19%2B0000&tab=logs

It should be: https://host/dags/dag_id/grid?tab=logs&dag_run_id=manual__2025-02-07T03%3A25%3A19.637151%2B00%3A00&task_id=xyz

Would appreciate any insights from the maintainers on this issue. Thanks!

What you think should happen instead?

https://host/dags/dag_id/grid?tab=logs&dag_run_id=manual__2025-02-07T03%3A25%3A19.637151%2B00%3A00&task_id=xyz

NOTE: Please verify once.

How to reproduce

  • Upgrade Airflow from 2.9.3 to 2.10.4.
  • Retrieve log_url from Airflow task instance metadata.
  • Compare the generated URL with the actual log view page in the UI.

Operating System

Linux

Versions of Apache Airflow Providers

2.10.4

Deployment

Official Apache Airflow Helm Chart

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

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 6
  • Comments: 15 (9 by maintainers)

Commits related to this issue

Most upvoted comments

@jason810496 Airflow has Airflow 3.0 after 2.10.5 directly. Is it possible to have 2.11?

Yes, there will be 2.11 release. You can check the 2.11.0 milestone that I just added this issue to.

BTW, I’m not sure will 3.0+ encounter the same issue or not, which will need further investigation.

UPDATE:

This error doesn’t occur in 3.0, as describe in: https://github.com/apache/airflow/pull/50306#pullrequestreview-2823808470

I’m on 2.10.5, what I found out is the logs URL works fine when the task run is triggered by a schedule, but when the task is triggered manually, the base_date value is a second short. base_date value is retrieved from the task’s execution date in the task instance. When the DAG is triggered manually, the task’s execution_date will include the micro seconds. So the pattern needs to change to %Y-%m-%dT%H:%M:%S.%f%Z to resolve the issue permanently.

I added a workaround in my callback function

def failure_callback(context):
    log_url = context.get("ti").log_url
    bad_section = f'&base_date={quote(context.get("ti").execution_date.strftime("%Y-%m-%dT%H:%M:%S%z"))}'
    replacement_section = f'&base_date={quote(context.get("ti").execution_date.strftime("%Y-%m-%dT%H:%M:%S.%f%z"))}'
    fixed_url = log_url.replace(bad_section, replacement_section)
    return fixed_url

@jason810496 Thanks for looking into this! To clarify, I am not referring to the log URL in the UI but rather the log_url property from TaskInstance, which I use in a Slack webhook notification for failed tasks. I am using task_instance.log_url in a Slack notifier to provide quick access to task logs when a DAG fails. However, due to the incorrect URL format in Airflow 2.10.4, clicking the log button in Slack does not redirect users correctly.

Notifier code block

{
    "type": "button",
    "text": {
        "type": "plain_text",
        "text": ":male-technologist: View Logs",
        "emoji": True
    },
    "value": "click_me_123",
    "action_id": "actionId-0",
    "url": task_instance.log_url  # This URL is broken in Airflow 2.10.4
}

Expected Behavior (Airflow 2.9.3)

  • Clicking the “View Logs” button in Slack should open the correct task log page.

Actual Behavior (Airflow 2.10.4)

  • The generated log_url contains an incorrect base_date query parameter, causing redirection issues.
  • Users cannot access task logs directly from Slack.

Steps to Reproduce the Issue

  1. Set up an Airflow DAG with a Slack webhook notification on task failure.
  2. Ensure the notification includes task_instance.log_url in the message.
  3. Trigger a task failure.
  4. Click the “View Logs” button in Slack.
  5. Observe that the URL does not lead to the expected log page.

To unblock my work, I have written my function to manually construct the correct log URL. However, since task_instance.log_url is an officially provided property, I wanted to report this as a potential bug because others relying on it may encounter similar issues.

Feel free 😃

Hi, I can try research on this issue 🙌