Don't mis-route nightly coverage comment to last-merged PR#849
Merged
mjp41 merged 1 commit intomicrosoft:mainfrom May 10, 2026
Merged
Don't mis-route nightly coverage comment to last-merged PR#849mjp41 merged 1 commit intomicrosoft:mainfrom
mjp41 merged 1 commit intomicrosoft:mainfrom
Conversation
The SHA-based fallback added in microsoft#847 (resolve PR by head SHA when `workflow_run.pull_requests[]` is empty) handles fork PRs correctly, but it also fires for `schedule` and `push` runs on `main`. The nightly's head SHA is the merge commit of whichever PR last landed, and `listPullRequestsAssociatedWithCommit` returns that PR — so the nightly coverage report ended up posted as a comment on the just- merged (now closed) PR instead of on the tracking issue. Two changes, both narrowing the fallback: 1. Only run the SHA fallback when `workflow_run.event === 'pull_request'`. `schedule`/`push` runs on the default branch always belong on the tracking issue and have no business looking up a PR by SHA. 2. Require the matched PR to be in the `open` state. The previous "fall back to any PR if only closed ones match (e.g. squash-merge race)" is undesirable: if the PR has already merged, posting a fresh coverage comment on it is noise, not information. If a contributor really wanted the comment on a merged PR they can re-run the workflow. Together these mean the SHA fallback only ever fires for an open fork PR, which is the only case it was ever meant to handle.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The SHA-based fallback added in #847 (resolve PR by head SHA when
workflow_run.pull_requests[]is empty) handles fork PRs correctly, but it also fires forscheduleandpushruns onmain. The nightly's head SHA is the merge commit of whichever PR last landed, andlistPullRequestsAssociatedWithCommitreturns that PR — so the nightly coverage report ended up posted as a comment on the just- merged (now closed) PR instead of on the tracking issue.Two changes, both narrowing the fallback:
Only run the SHA fallback when
workflow_run.event === 'pull_request'.schedule/pushruns on the default branch always belong on the tracking issue and have no business looking up a PR by SHA.Require the matched PR to be in the
openstate. The previous "fall back to any PR if only closed ones match (e.g. squash-merge race)" is undesirable: if the PR has already merged, posting a fresh coverage comment on it is noise, not information. If a contributor really wanted the comment on a merged PR they can re-run the workflow.Together these mean the SHA fallback only ever fires for an open fork PR, which is the only case it was ever meant to handle.