Skip to content

gh run download: prefer newest artifact when names collide#12503

Open
VedantMadane wants to merge 2 commits intocli:trunkfrom
VedantMadane:fix/run-download-latest-artifact
Open

gh run download: prefer newest artifact when names collide#12503
VedantMadane wants to merge 2 commits intocli:trunkfrom
VedantMadane:fix/run-download-latest-artifact

Conversation

@VedantMadane
Copy link

Fixes #12437.

When a workflow run is re-run, GitHub can return multiple artifacts with the same name (one per attempt). gh run download --name previously downloaded the first occurrence and then deduped by name, which could pick an older attempt.

This change:

  • Captures created_at for artifacts
  • Sorts artifacts newest-first before selecting per-name
  • Adds a regression test demonstrating the newer artifact is chosen when names collide

@VedantMadane VedantMadane requested a review from a team as a code owner January 20, 2026 18:15
@VedantMadane VedantMadane requested a review from babakks January 20, 2026 18:15
@cliAutomation cliAutomation added the external pull request originating outside of the CLI core team label Jan 20, 2026
@github-actions
Copy link

Thank you for your pull request! 🎉

This PR appears to fix the following issues that are not labeled with help wanted Contributions welcome :

As outlined in our Contributing Guidelines, we expect that PRs are only created for issues that have been labeled help wanted.

While we appreciate your initiative, please note that:

  • PRs for non-help wanted issues may not be reviewed immediately as they might not align with our current priorities
  • The issue might already be assigned to a team member or planned for a specific release
  • We may need to close this PR. For example, if it conflicts with ongoing work or architectural decisions

What happens next:

  • Our team will review this PR and the associated issues
  • We may add the help wanted label to the issues, if appropriate, and review this pull request
  • In some cases, we may need to close the PR. For example, if it doesn't fit our current roadmap

Thank you for your understanding and contribution to the project! 🙏

This comment was automatically generated by cliAutomation.

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

Labels

external pull request originating outside of the CLI core team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gh run download doesn't download latest artifact

2 participants