Skip to content

context["ti"].log_url returns unuseable value #54247

@jessicaschueler

Description

@jessicaschueler

Apache Airflow version

3.0.3

If "Other Airflow 2 version" selected, which one?

No response

What happened?

The method get_log_url_from_ti of RuntimeTaskInstance contains a typo that returns an inaccessible URL.

The string is currently formatted;
_log_uri = f"{base_url}dags/{ti.dag_id}/runs/{run_id}/tasks/{ti.task_id}{map_index}{try_number}"

What you think should happen instead?

To correct this, a forward slash should be added
_log_uri = f"{base_url}/dags/{ti.dag_id}/runs/{run_id}/tasks/{ti.task_id}{map_index}{try_number}"

How to reproduce

The following dag code will print the url

from airflow.decorators import dag, task
from pendulum import datetime

@dag(
    start_date=datetime(2024, 1, 1),
    schedule="@daily",
    catchup=False,
    doc_md=__doc__,
    default_args={"retries": 3},
    tags=["example"],
)
def example_url():
    # Define tasks
    @task
    def print_log_url(**context) -> None:
        url = context["ti"].log_url
        print(f"log_url is {url}")

    print_log_url()
example_url()
Image

The address produced returns an error

Operating System

mac 15.5 (24F74)

Versions of Apache Airflow Providers

No response

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    affected_version:3.0Issues Reported for 3.0area:corekind:bugThis is a clearly a bugpriority:mediumBug that should be fixed before next release but would not block a release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions