oboki commented on code in PR #50175: URL: https://github.com/apache/airflow/pull/50175#discussion_r2077980085
########## airflow-core/src/airflow/utils/log/file_task_handler.py: ########## @@ -474,6 +480,20 @@ def _get_log_retrieval_url( hostname = ti.triggerer_job.hostname log_relative_path = self.add_triggerer_suffix(log_relative_path, job_id=ti.triggerer_job.id) else: + from airflow.models.taskinstancehistory import TaskInstanceHistory + + ti = ( + session.query(TaskInstanceHistory) + .filter( + TaskInstanceHistory.dag_id == ti.dag_id, + TaskInstanceHistory.task_id == ti.task_id, + TaskInstanceHistory.run_id == ti.run_id, + TaskInstanceHistory.map_index == ti.map_index, + TaskInstanceHistory.try_number == try_number, + ) + .one_or_none() + or ti + ) Review Comment: In my previous attempt, I ran into a type issue right from the beginning, like this: ```python Traceback (most recent call last): File "/home/airflow/.local/lib/python3.12/site-packages/airflow/utils/log/file_task_handler.py", line 589, in _read_from_logs_server log_type = LogType.TRIGGER if ti.triggerer_job else LogType.WORKER ^^^^^^^^^^^^^^^^ AttributeError: 'TaskInstanceHistory' object has no attribute 'triggerer_job' ``` So I didn't dig much deeper at the time. But after working around this `AttributeError`, your approach looks much simpler! I'm currently using airflow 2.10, so I didn't quite catch your suggestion at first, as the webserver has changed quite a bit in 3.0. But now it finally makes sense. Thanks again! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org