Skip to content

Use intake artifact metadata for PR resolution and improve parse diagnostics#8471

Open
WaelAbuSeada wants to merge 1 commit into
mainfrom
private/waabusea/FixPRAgent1
Open

Use intake artifact metadata for PR resolution and improve parse diagnostics#8471
WaelAbuSeada wants to merge 1 commit into
mainfrom
private/waabusea/FixPRAgent1

Conversation

@WaelAbuSeada
Copy link
Copy Markdown
Member

@WaelAbuSeada WaelAbuSeada commented Jun 3, 2026

Summary

  • resolve PR metadata in Copilot PR Review Runner from the intake artifact (pr-metadata.json) downloaded from the triggering workflow run
  • simplify runner resolution flow by removing branch/search fallback logic and keeping strict head SHA validation
  • improve review script parse diagnostics by logging candidate index/hash/length/preview and writing parse diagnostics to a dedicated artifact file

Validation

  • verified workflow YAML parses without errors
  • confirmed script changes compile with existing repository warnings only (no new script diagnostics introduced)
    Fixes AB#637653

…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
@WaelAbuSeada WaelAbuSeada requested review from a team as code owners June 3, 2026 22:45
@github-actions github-actions Bot added the Build: Automation Workflows and other setup in .github folder label Jun 3, 2026
@github-actions github-actions Bot added this to the Version 29.0 milestone Jun 3, 2026
}

if (-not $prNumber) {
throw 'No pull request number found in workflow_run payload or fallback PR lookup.'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

$\textbf{🟠\ High\ Severity\ —\ Upgrade} \quad \color{gray}{\texttt{\small Iteration\ 1}}$

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

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

Labels

Build: Automation Workflows and other setup in .github folder

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant