Skip to content

artifact: pick the newest artifact by creation time, not by ID - #2540

Open
ctbot000 wants to merge 1 commit into
actions:mainfrom
ctbot000:artifact-newest-by-created-at
Open

ctbot000 wants to merge 1 commit into
actions:mainfrom
ctbot000:artifact-newest-by-created-at

Conversation

@ctbot000

@ctbot000 ctbot000 commented Oct 8, 2026

Copy link
Copy Markdown

When several artifacts share a name, which happens when a re-run uploads an artifact again, getArtifact and listArtifacts({latest: true}) return the one with the highest ID as the newest. Artifact IDs are not assigned in creation order, so the newer artifact can have the lower ID, and the older one is returned. download-artifact uses both, so downloading by name in a re-run can silently fetch the previous attempt's artifact.

Two public runs show IDs out of creation order:

  • ctbot000/kids-world run 37629390230: the first attempt uploaded github-pages at 13:43:59Z with ID 11486441618, and the re-run uploaded github-pages at 13:44:49Z with ID 11485144989. See the "successfully finalized" lines in the deploy jobs of attempt 1 and attempt 2.
  • ctbot000/jvm-inspector run 35733432988: four matrix jobs uploaded artifacts between 13:26:42Z and 13:27:01Z with IDs 10696995222, 10696442090, 10696412148 and 10696746841, in that order.

Across 37 artifacts in 7 repositories, a later artifact had the lower ID in 15 of 666 pairs.

Changes

  • Add compareNewestFirst, which orders artifacts by createdAt and uses the ID only to break ties. An artifact without a creation time counts as the oldest.
  • Use it in getArtifactPublic, getArtifactInternal and filterLatest. The two getArtifact functions now map the response to Artifact before picking one, so a single comparator serves all three.
  • Tests for the comparator, and for getArtifact and listArtifacts with latest, public and internal, given two artifacts whose IDs run against their creation times. Those four tests fail without the fix.

npm run build, npm test -- packages/artifact (173 tests), npm run lint and npm run format-check pass locally on Node 24. I left the version bump and RELEASES.md to you.

🤖 Generated with Claude Code

getArtifact and listArtifacts({latest: true}) treated the artifact with
the highest ID as the newest one. IDs are not assigned in creation
order, though: when a re-run uploads an artifact with the same name
again, the newer artifact can get the lower ID, and the older one was
returned. Sort by creation time instead and use the ID only to break
ties.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ctbot000
ctbot000 requested a review from a team as a code owner October 8, 2026 16:12

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant