You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ep...@apache.org on 2023/08/03 12:36:07 UTC
[airflow] 05/09: Use string concatenation for prepending base URL for log_url (#33063)
This is an automated email from the ASF dual-hosted git repository.
ephraimanierobi pushed a commit to branch v2-7-test
in repository https://gitbox.apache.org/repos/asf/airflow.git
commit 868d1389461822cf5d54faaff3ce19913fc7f08e
Author: Pankaj Koti <pa...@gmail.com>
AuthorDate: Thu Aug 3 14:49:21 2023 +0530
Use string concatenation for prepending base URL for log_url (#33063)
It is observed that urljoin is not yielding expected results for
the task instance's log_url which needs to be a concatenation of the
webserver base_url and specified relative url. The current usage
of urljoin does not seem to be the right way to achieve this based
on what urljoin is meant for and how it works. So, we use simple
string concatenation to yield the desired result.
More context in the comment https://github.com/apache/airflow/pull/31833#discussion_r1282696916
closes: #32996
(cherry picked from commit baa1bc0438baa05d358b236eec3c343438d8d53c)
---
airflow/models/taskinstance.py | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/airflow/models/taskinstance.py b/airflow/models/taskinstance.py
index eb6388ca3d..4012b09d2c 100644
--- a/airflow/models/taskinstance.py
+++ b/airflow/models/taskinstance.py
@@ -33,7 +33,7 @@ from functools import partial
from pathlib import PurePath
from types import TracebackType
from typing import TYPE_CHECKING, Any, Callable, Collection, Generator, Iterable, Tuple
-from urllib.parse import quote, urljoin
+from urllib.parse import quote
import dill
import jinja2
@@ -779,26 +779,28 @@ class TaskInstance(Base, LoggingMixin):
"""Log URL for TaskInstance."""
iso = quote(self.execution_date.isoformat())
base_url = conf.get_mandatory_value("webserver", "BASE_URL")
- return urljoin(
- base_url,
- f"log?execution_date={iso}"
+ return (
+ f"{base_url}"
+ "/log"
+ f"?execution_date={iso}"
f"&task_id={self.task_id}"
f"&dag_id={self.dag_id}"
- f"&map_index={self.map_index}",
+ f"&map_index={self.map_index}"
)
@property
def mark_success_url(self) -> str:
"""URL to mark TI success."""
base_url = conf.get_mandatory_value("webserver", "BASE_URL")
- return urljoin(
- base_url,
- f"confirm?task_id={self.task_id}"
+ return (
+ f"{base_url}"
+ "/confirm"
+ f"?task_id={self.task_id}"
f"&dag_id={self.dag_id}"
f"&dag_run_id={quote(self.run_id)}"
"&upstream=false"
"&downstream=false"
- "&state=success",
+ "&state=success"
)
@provide_session