KEMBAR78
Resolve to new job run log when both old and new logs are present · Issue #10768 · cli/cli · GitHub
Skip to content

Resolve to new job run log when both old and new logs are present #10768

@babakks

Description

@babakks

Description

Note

This is a follow up to this comment on #10740.

Sometimes when the CLI downloads the ZIP archive of a workflow run, two top-level .txt files are in the archive, both of which supposed to contain the logs for an entire job run. Here is an example:

$ gh run view --log -R cli/cli 14233257584
$ unzip -l ~/.cache/gh/run-log-14233257584-1743645262.zip
Archive:  run-log-14233257584-1743645262.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
      808  2025-04-03 17:30   issue-auto/2_label incoming issue.txt
      510  2025-04-03 17:30   -2147483648_issue-auto.txt                      <<< Here
        0  2025-04-03 17:30   issue-auto/
     2580  2025-04-03 17:30   0_issue-auto.txt                                <<< & here
     1289  2025-04-03 17:30   issue-auto/1_Set up job.txt
       58  2025-04-03 17:30   issue-auto/3_Complete job.txt
---------                     -------
     5245                     6 files

Here, both normal and legacy top-level .txt files are there, and their contents are different (See below). Supposedly, The legacy file (i.e., -2147483648_issue-auto.txt) should be produced by the API when it couldn't find the data of a run; however, in this case, this is not a correct assumption.

For this particular example, since the step logs are also there, when we do gh run view --log the output is fine because the step logs are the preferred source of data for the CLI.

The problem surfaces when there are no step logs. In such cases CLI falls back to display the entire job run log, and to do that it picks one of the top-level .txt files, depending on the ZIP content's ordering. The implementation should be fixed so that it prefers the 0_issue-auto.txt over the legacy log file (i.e., -2147483648_issue-auto.txt).

File contents

-2147483648_issue-auto.txt:

2025-04-03T01:54:23.1894394Z ##[section]Starting: Prepare job issue-auto
2025-04-03T01:54:23.1896693Z Evaluating strategy
2025-04-03T01:54:23.1901835Z Creating job '__default'
2025-04-03T01:54:23.1904320Z Evaluating timeout
2025-04-03T01:54:23.1904373Z Evaluating cancel timeout
2025-04-03T01:54:23.1904415Z Evaluating continue on error
2025-04-03T01:54:23.1904441Z Evaluating target
2025-04-03T01:54:23.1904913Z Evaluating environment
2025-04-03T01:54:23.1906350Z ##[section]Finishing: Prepare job issue-auto

0_issue-auto.txt:

2025-04-03T01:54:23.7907259Z Requested labels: ubuntu-latest
2025-04-03T01:54:23.7907520Z Job defined at: cli/cli/.github/workflows/issueauto.yml@refs/heads/trunk
2025-04-03T01:54:23.7907618Z Waiting for a runner to pick up this job...
2025-04-03T01:54:24.2730185Z Job is waiting for a hosted runner to come online.
2025-04-03T01:54:26.9708943Z Job is about to start running on the hosted runner: GitHub Actions 693 (hosted)
2025-04-03T01:54:28.8828327Z Current runner version: '2.323.0'
2025-04-03T01:54:28.8857448Z ##[group]Operating System
2025-04-03T01:54:28.8858217Z Ubuntu
2025-04-03T01:54:28.8858729Z 24.04.2
2025-04-03T01:54:28.8859319Z LTS
2025-04-03T01:54:28.8859772Z ##[endgroup]
2025-04-03T01:54:28.8860299Z ##[group]Runner Image
2025-04-03T01:54:28.8860943Z Image: ubuntu-24.04
2025-04-03T01:54:28.8861475Z Version: 20250316.1.0
2025-04-03T01:54:28.8862551Z Included Software: https://github.com/actions/runner-images/blob/ubuntu24/20250316.1/images/ubuntu/Ubuntu2404-Readme.md
2025-04-03T01:54:28.8863985Z Image Release: https://github.com/actions/runner-images/releases/tag/ubuntu24%2F20250316.1
2025-04-03T01:54:28.8864920Z ##[endgroup]
2025-04-03T01:54:28.8865511Z ##[group]Runner Image Provisioner
2025-04-03T01:54:28.8866268Z 2.0.422.1
2025-04-03T01:54:28.8866896Z ##[endgroup]
2025-04-03T01:54:28.8867997Z ##[group]GITHUB_TOKEN Permissions
2025-04-03T01:54:28.8869791Z Issues: write
2025-04-03T01:54:28.8870441Z Metadata: read
2025-04-03T01:54:28.8871128Z ##[endgroup]
2025-04-03T01:54:28.8874087Z Secret source: Actions
2025-04-03T01:54:28.8874824Z Prepare workflow directory
2025-04-03T01:54:28.9179205Z Prepare all required actions
2025-04-03T01:54:28.9269537Z Complete job name: issue-auto
2025-04-03T01:54:29.0127709Z ##[group]Run if ! gh api orgs/cli/public_members/$ISSUEAUTHOR --silent 2>/dev/null
2025-04-03T01:54:29.0128780Z if ! gh api orgs/cli/public_members/$ISSUEAUTHOR --silent 2>/dev/null
2025-04-03T01:54:29.0129485Z then
2025-04-03T01:54:29.0129996Z   gh issue edit $ISSUENUM --add-label "needs-triage"
2025-04-03T01:54:29.0130596Z fi
2025-04-03T01:54:29.0614473Z shell: /usr/bin/bash -e {0}
2025-04-03T01:54:29.0615274Z env:
2025-04-03T01:54:29.0615669Z   GH_REPO: cli/cli
2025-04-03T01:54:29.0616625Z   GH_TOKEN: ***
2025-04-03T01:54:29.0617062Z   ISSUENUM: 10725
2025-04-03T01:54:29.0617629Z   ISSUEAUTHOR: saidakrommuminov52
2025-04-03T01:54:29.0618121Z ##[endgroup]
2025-04-03T01:54:30.4210011Z https://github.com/cli/cli/issues/10725
2025-04-03T01:54:30.4302059Z Cleaning up orphan processes

Acceptance Criteria

1. Both new and legacy job run log files in the archive

Given I have a job run whose logs include both new and legacy job run logs
When I run gh run view --logs <JOB-ID>
Then the content of the new job run log file is displayed

2. Only new job run log files in the archive

Given I have a job run whose logs include only the new job run logs
When I run gh run view --logs <JOB-ID>
Then the content of the new job run log file is displayed

3. Only legacy job run log files in the archive

Given I have a job run whose logs include only the legacy job run logs
When I run gh run view --logs <JOB-ID>
Then the content of the legacy job run log file is displayed

Metadata

Metadata

Assignees

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