Skip to content

gh run view --log with duplicate job names incorrectly shows the same log twice #7641

@williammartin

Description

@williammartin

Describe the bug

This is a spinoff from #5011

Given two jobs in a workflow that have the same name, gh run view --log will incorrectly show the same log twice rather than the actual log for each independent job.

Steps to reproduce the behavior

Here is a workflow definition that produces the same job name twice.

Running gh run view 5415196651 --log produces the same log twice, as we can see by the random number produced (output snipped for readability):

duplicate       Set up job      2023-06-29T18:16:44.1239045Z Complete job name: duplicate
duplicate       Run echo "Random number: ${RANDOM}"     2023-06-29T18:16:44.2623378Z ##[group]Run echo "Random number: ${RANDOM}"
duplicate       Run echo "Random number: ${RANDOM}"     2023-06-29T18:16:44.2624075Z echo "Random number: ${RANDOM}"
duplicate       Run echo "Random number: ${RANDOM}"     2023-06-29T18:16:44.3460078Z shell: /usr/bin/bash -e {0}
duplicate       Run echo "Random number: ${RANDOM}"     2023-06-29T18:16:44.3460624Z ##[endgroup]
duplicate       Run echo "Random number: ${RANDOM}"     2023-06-29T18:16:44.4148078Z Random number: 10677
duplicate       Complete job    2023-06-29T18:16:44.4479521Z Cleaning up orphan processes
...
duplicate       Run echo "Random number: ${RANDOM}"     2023-06-29T18:16:44.2623378Z ##[group]Run echo "Random number: ${RANDOM}"
duplicate       Run echo "Random number: ${RANDOM}"     2023-06-29T18:16:44.2624075Z echo "Random number: ${RANDOM}"
duplicate       Run echo "Random number: ${RANDOM}"     2023-06-29T18:16:44.3460078Z shell: /usr/bin/bash -e {0}
duplicate       Run echo "Random number: ${RANDOM}"     2023-06-29T18:16:44.3460624Z ##[endgroup]
duplicate       Run echo "Random number: ${RANDOM}"     2023-06-29T18:16:44.4148078Z Random number: 10677
duplicate       Complete job    2023-06-29T18:16:44.4479521Z Cleaning up orphan processes

Expected vs actual behavior

As seen in the web job logs, the random number produced for the second job was different. I would expect it to show the same logs as the web UI.

Why does this happen?

As described in my comment when the .zip file is produced, there is an attempt to make file names unique because job name uniqueness is not guaranteed. This is done by appending a counter to the end of the filepath inside the .zip as seen in the shell output below. Our regexp matching logic does not apply the same behaviour, resulting in us not matching file names to their jobs.

➜  run-log-5415196651-1688062594 ls -lah
total 32
-rw-r--r--  1 williammartin  staff   2.1K Jun 29 18:17 1_duplicate (1).txt
-rw-r--r--  1 williammartin  staff   2.1K Jun 29 18:17 1_duplicate (2).txt
-rw-r--r--  1 williammartin  staff   448B Jun 29 18:17 1_duplicate.txt
-rw-r--r--  1 williammartin  staff   450B Jun 29 18:17 2_duplicate.txt
drwxr-xr-x  5 williammartin  staff   160B Jun 29 20:18 duplicate
drwxr-xr-x  5 williammartin  staff   160B Jun 29 20:18 duplicate (1)

Notes

Related issues: #7640, #7642

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcoreThis issue is not accepting PRs from outside contributorsgh-runrelating to the gh run commandp2Affects more than a few users but doesn't prevent core functions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions