Skip to content

Use Actions API to retrieve job run logs as a fallback mechanism #11169

Description

@babakks

This issue is a follow-up to #11118.

We want to use the Actions API (here) as a fallback mechanism to retrieve job run logs when the current approach (extracting logs from a downloaded ZIP archive) fails.

Other context

  • If there's 1 job log missing, there are probably others, but fixing that holistically is a larger conversation with the Actions team.
  • It's common for projects to have a lot of logs for matrix workflows.

As a middle ground to avoid hitting the API too many times in case of huge runs (lots of jobs), we need to apply a restriction on the number of fallback API calls, and display an actionable error message to users.

Acceptance Criteria

1. Fallback to API call

Given I have a job run that is missing from the downloaded ZIP archive
When I run gh run view --log -j <JOB-RUN-ID>
Then I see the job logs, with the step name column filled with "UNKNOWN STEP"

Note

Reproducing this with read data is a bit tricky. Since this fix coincidentally fixes the cases reported in #10868, we can also use those cases to verify the current PR.

2. Error when too many API calls are needed

Given I have a workflow run where more than 25 job log files are missing from the downloaded ZIP archive
When I run gh run view --log <RUN-ID>
Then I get an error indicating I should use the --job option (without any API calls being made)

Activity

  1. self-assigned this
    on Jun 25, 2025
  2. added
    enhancementa request to improve CLI
    coreThis issue is not accepting PRs from outside contributors
    gh-runrelating to the gh run command
    on Jun 25, 2025
  3. self-assigned this
    on Jul 4, 2025
  4. basaveswar-kureti commented on Jul 14, 2025

    @basaveswar-kureti

    @babakks We are on the latest version 2.75.0 where this issue is fixed, but we are still seeing this.
    gh --version gh version 2.75.0 (2025-07-09) https://github.com/cli/cli/releases/tag/v2.75.0

    We have a job skipped due to the conditionals. Does this handles that case ?
    Currently it is failing with the error:

    gh --repo abcd/xyz run view 16266528487 --log
    ...
    ...
    log not found: 45923553930
    

    45923553930 --> This corresponds to the skipped job id

  5. babakks commented on Jul 16, 2025

    @babakks
    MemberAuthor

    Thanks for reporting this, @basaveswar-kureti! 🙏

    There's a new issue opened for this (#11311), so please follow up on the updates in there.

  6. basaveswar-kureti commented on Jul 16, 2025

    @basaveswar-kureti

    Thanks @babakks for your response. Looking forward for the fix. I will be happy to verify the fix.
    Please let me know if you need any debug info/logs from my end.

  7. babakks commented on Jul 16, 2025

    @babakks
    MemberAuthor

    Thanks for your offering, @basaveswar-kureti! I've made PR #11312 which is now pending review. You can check out the PR branch and try building gh from source. If you did that, please let me know your thoughts/observations.

  8. basaveswar-kureti commented on Jul 17, 2025

    @basaveswar-kureti

    Thanks @babakks for the quick fix. I verified and it is working properly.

    % /opt/homebrew/bin/gh --repo abcd/xyz run view 16266528487 --log | grep "log not found"
    log not found: 45923553930
    % ./gh --repo abcd/xyz run view 16266528487 --log | grep "log not found"
    % ./gh version
    gh version 2.75.1-3-gf67bd9a7d (2025-07-17)
    https://github.com/cli/cli/releases/latest
    % git status 
    On branch babakks/avoid-fetching-logs-for-skipped-jobs
    Your branch is up to date with 'origin/babakks/avoid-fetching-logs-for-skipped-jobs'.
    
    nothing to commit, working tree clean
    
  9. babakks commented on Jul 17, 2025

    @babakks
    MemberAuthor

    Thanks for trying the changes. However, since the error message is printed on stderr the | grep wouldn't surface it. You can try 2>&1 | grep or simply |& grep.

    Anyway, the PR is on our review list and should be merged before the next release, which is probably due next week. Things can always change, though, so that's just an estimation.

  10. basaveswar-kureti commented on Jul 17, 2025

    @basaveswar-kureti

    @babakks Checked with 2>&1. It is working as expected.

    Thanks for the estimated release date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

coreThis issue is not accepting PRs from outside contributorsenhancementa request to improve CLIgh-runrelating to the gh run command

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions