Use intake artifact metadata for PR resolution and improve parse diagnostics#8471
Open
WaelAbuSeada wants to merge 1 commit into
Open
Use intake artifact metadata for PR resolution and improve parse diagnostics#8471WaelAbuSeada wants to merge 1 commit into
WaelAbuSeada wants to merge 1 commit into
Conversation
…nostics - make Copilot PR Review Runner resolve PR details from downloaded intake artifact metadata - remove workflow fallback lookup complexity and keep strict SHA validation - enhance JSON parse diagnostics with candidate index/hash/length and dedicated parse-errors artifact file
| } | ||
|
|
||
| if (-not $prNumber) { | ||
| throw 'No pull request number found in workflow_run payload or fallback PR lookup.' |
Contributor
There was a problem hiding this comment.
No fallback if artifact metadata is missing
The old runner had a robust fallback: search GitHub's API for open PRs by head SHA when workflow_run.pull_requests[0].number was absent. The new code silently catches artifact errors and then immediately throws with no recovery. Any workflow_run event where the artifact upload failed, was slow, or used a different naming pattern will cause hard failures with no self-healing.
Recommendation:
- Keep the old API-search fallback as a secondary path when artifact resolution fails, matching PRs by
expectedHeadSha.
Suggested change
| throw 'No pull request number found in workflow_run payload or fallback PR lookup.' | |
| # After try/catch for artifact, if -not $prNumber: | |
| $encodedHead = [System.Uri]::EscapeDataString("${headOwner}:${headBranch}") | |
| $candidates = Invoke-RestMethod -Uri "https://api.github.com/repos/${{ github.repository }}/pulls?state=open&head=$encodedHead&per_page=30" -Headers $headers -Method GET | |
| $match = @($candidates | Where-Object { $_.head.sha -eq $expectedHeadSha }) | |
| if ($match.Count -eq 1) { $prNumber = [string]$match[0].number } |
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why
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.
Summary
Validation
Fixes AB#637653