Skip to content

Comment on the newest run for the PR branch to fix lost and stale changelog comments - #422

Merged
Mpdreamz merged 2 commits into
mainfrom
fix-stale-comment-run
Oct 14, 2026
Merged

Mpdreamz merged 2 commits into
mainfrom
fix-stale-comment-run

Conversation

@Mpdreamz

Copy link
Copy Markdown
Member

The changelog comment job now posts the newest completed run's decision for the PR branch, whichever run triggered the job. This removes two races that leave a wrong or missing changelog comment when runs start close together.

Why

Each comment job downloaded the artifact of the run that triggered it, and skipped itself only if a newer run existed for the same commit. Two cases slipped through:

  • Stale decision wins. A PR opened, then pushed a second commit a few seconds later, starts two runs on two commits. The older run's job can finish last, see no newer run for its own commit, and overwrite or delete the newer comment. In the playground repository, a passing run for the first commit deleted the entries-invalid comment that the second commit had just posted.
  • The newest decision is never posted. The caller's concurrency group keeps one pending job and cancels the rest. With three runs close together, the job of the newest run can be the one cancelled. The surviving jobs belong to older runs, so they skip as superseded and nobody comments. A PR opened with two labels did this.

What

Resolve the run to comment on

changelog/comment/action.yml lists the workflow's runs for the PR's head repository and branch, ignores cancelled runs, and takes the newest. Whichever job survives posts that run's artifact. If the newest run is still in progress, the job skips, because that run's own completion triggers another job. If the list is empty, the job falls back to the triggering run. Branch values reach the script through env, not through the expression.

Out of scope: The caller templates keep their concurrency group. It still serializes the comment jobs of different upstream workflows on one PR.

Verify

workflow_run workflows run from the default branch, so this cannot run end to end from a PR branch. I ran the extracted script against live runs in elastic/docs-playground-release-notes-tagged, replaying the failure above:

# triggering run: an older run for an older commit on test/entry-invalid
RUN_ID=38562694854 HEAD_BRANCH=test/entry-invalid EVENT=pull_request ... bash resolve.sh
# Commenting on the newest run 38569241264 instead of the triggering run 38562694854.

The selection was also checked against a fixture with a cancelled run, a run from another fork, a newer in-progress run, and no runs. zizmor reports no findings.

After merge, open a PR in a repository that uses the release notes workflows, add two labels at once, and push twice within a second. The final comment should match the last run.

🤖 Generated with Claude Code

Each comment job read the artifact of the run that triggered it. An older run's job could land last and overwrite a newer decision, and the caller's concurrency group could cancel the job of the newest run and leave nobody to post it. Every job now resolves the newest completed run of the workflow for the PR branch and comments on that, whichever run triggered the job.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@Mpdreamz
Mpdreamz requested a review from a team as a code owner October 14, 2026 13:17
@Mpdreamz Mpdreamz added the bug Something isn't working label Oct 14, 2026
@Mpdreamz
Mpdreamz requested a review from akira28 October 14, 2026 13:17

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes: the new run-selection and artifact checks currently swallow API/query failures, which can cause stale decisions to be posted or expected comments to be skipped silently.


What is this? | From workflow: PR Review

Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not.

Comment thread changelog/comment/action.yml Resolved
Comment thread changelog/comment/action.yml Resolved
A failed run listing fell back to the triggering run, which could post a stale decision, and a failed artifact listing became exists=false, which skipped the comment silently. Both calls are now retried and then fail the step with an error, so a query failure no longer reads as "nothing found".

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved — no remaining actionable issues found on the current revision.


What is this? | From workflow: PR Review

Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not.

@Mpdreamz
Mpdreamz merged commit f7d2db3 into main Oct 14, 2026
10 checks passed
@Mpdreamz
Mpdreamz deleted the fix-stale-comment-run branch October 14, 2026 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants