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
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?
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
- I agree to follow this project’s Code of Conduct
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 6
- Comments: 15 (9 by maintainers)
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_datevalue is a second short.base_datevalue is retrieved from the task’s execution date in the task instance. When the DAG is triggered manually, the task’sexecution_datewill include the micro seconds. So the pattern needs to change to%Y-%m-%dT%H:%M:%S.%f%Zto resolve the issue permanently.I added a workaround in my callback function
@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
Expected Behavior (Airflow 2.9.3)
Actual Behavior (Airflow 2.10.4)
Steps to Reproduce the Issue
To unblock my work, I have written my function to manually construct the correct log URL. However, since
task_instance.log_urlis 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 🙌