airflow icon indicating copy to clipboard operation
airflow copied to clipboard

grid view: first mapped task logs link points to map index: -1, should point to 0

Open MatrixManAtYrService opened this issue 3 years ago • 2 comments

Apache Airflow version

main (development)

What happened

Any mapped task will do, but here's a DAG with two:

with DAG(
    dag_id="zip_tf",
    schedule_interval=timedelta(days=30 * 365),
    start_date=datetime(1970, 1, 1),
) as zip_tf:

    @task
    def get_template():
        return ["hello {}", "goodbye {}"]

    @task
    def get_user():
        return ["foo", "bar"]

    @task
    def salutations(arg):
        print(arg[0].format(arg[1]))

    combined = get_template().zip(get_user())
    salutations.expand(arg=combined)

If you run it and navigate to the graph view, you can view the logs for both mapped tasks ("hello foo" and "goodbye bar"). But if you try to do the same thing via the grid view, you can only view the second one ("goodbye bar"). This is because the link to view the first one's logs is pointing to:

http://localhost:8080/log?dag_id=zip_tf&dag_id=zip_tf&task_id=salutations&execution_date=1970-01-01T00%3A00%3A00%2B00%3A00&map_index=-1

But -1 is used for when there are no mapped tasks, not for the first one. So when you follow the link, you don't see any logs at all.

neg

What you think should happen instead

the correct logs should appear

How to reproduce

see above

Operating System

NixOS (linux)

Versions of Apache Airflow Providers

n/a

Deployment

Virtualenv installation

Deployment details

LocalExecutor

Anything else

No response

Are you willing to submit PR?

  • [ ] Yes I am willing to submit a PR!

Code of Conduct

MatrixManAtYrService avatar Aug 09 '22 07:08 MatrixManAtYrService

Good catch. We're about to update mapped task logs in https://github.com/apache/airflow/pull/25610. We can fix it as part of that.

bbovenzi avatar Aug 09 '22 14:08 bbovenzi

Thanks for reporting the bug. I think it had something to do with 0 beeing falsy. It is handled in #25610

pierrejeambrun avatar Aug 09 '22 15:08 pierrejeambrun