Skip to content

Commit 1838602

Browse files
authored
Properly build URL to retrieve logs independently from system (#26337)
The previous way of building the path depended on the OS path but it was really used to build the URL so we should use urllib instead of os.path.join.
1 parent 23ad7e2 commit 1838602

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

airflow/utils/log/file_task_handler.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import warnings
2222
from pathlib import Path
2323
from typing import TYPE_CHECKING, Optional
24+
from urllib.parse import urljoin
2425

2526
from airflow.configuration import AirflowConfigException, conf
2627
from airflow.exceptions import RemovedInAirflow3Warning
@@ -194,8 +195,8 @@ def _read(self, ti, try_number, metadata=None):
194195
else:
195196
import httpx
196197

197-
url = os.path.join("http://{ti.hostname}:{worker_log_server_port}/log", log_relative_path).format(
198-
ti=ti, worker_log_server_port=conf.get('logging', 'WORKER_LOG_SERVER_PORT')
198+
url = urljoin(
199+
f"http://{ti.hostname}:{conf.get('logging', 'WORKER_LOG_SERVER_PORT')}/log", log_relative_path
199200
)
200201
log += f"*** Log file does not exist: {location}\n"
201202
log += f"*** Fetching from: {url}\n"

0 commit comments

Comments
 (0)