You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by hu...@apache.org on 2024/07/13 14:56:07 UTC

(airflow) branch main updated: Fix and adjust URL generation for UI grid and older runs (#40764)

This is an automated email from the ASF dual-hosted git repository.

husseinawala pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 9c13c0939a Fix and adjust URL generation for UI grid and older runs (#40764)
9c13c0939a is described below

commit 9c13c0939acc6b7dbd856c12c6eba12182fe00a0
Author: Jens Scheffler <95...@users.noreply.github.com>
AuthorDate: Sat Jul 13 16:55:59 2024 +0200

    Fix and adjust URL generation for UI grid and older runs (#40764)
---
 airflow/models/taskinstance.py    | 5 ++++-
 tests/models/test_taskinstance.py | 2 +-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/airflow/models/taskinstance.py b/airflow/models/taskinstance.py
index 9d248f4db1..599c21306b 100644
--- a/airflow/models/taskinstance.py
+++ b/airflow/models/taskinstance.py
@@ -2164,7 +2164,9 @@ class TaskInstance(Base, LoggingMixin):
     def log_url(self) -> str:
         """Log URL for TaskInstance."""
         run_id = quote(self.run_id)
+        base_date = quote(self.execution_date.strftime("%Y-%m-%dT%H:%M:%S%z"))
         base_url = conf.get_mandatory_value("webserver", "BASE_URL")
+        map_index = f"&map_index={self.map_index}" if self.map_index >= 0 else ""
         return (
             f"{base_url}"
             f"/dags"
@@ -2172,7 +2174,8 @@ class TaskInstance(Base, LoggingMixin):
             f"/grid"
             f"?dag_run_id={run_id}"
             f"&task_id={self.task_id}"
-            f"&map_index={self.map_index}"
+            f"{map_index}"
+            f"&base_date={base_date}"
             "&tab=logs"
         )
 
diff --git a/tests/models/test_taskinstance.py b/tests/models/test_taskinstance.py
index 5a8d6139a2..c22c0c2794 100644
--- a/tests/models/test_taskinstance.py
+++ b/tests/models/test_taskinstance.py
@@ -2020,7 +2020,7 @@ class TestTaskInstance:
             "/dags/my_dag/grid"
             "?dag_run_id=test"
             "&task_id=op"
-            "&map_index=-1"
+            "&base_date=2018-01-01T00%3A00%3A00%2B0000"
             "&tab=logs"
         )
         assert ti.log_url == expected_url