Repository: dotnet/runtime
File: .github/skills/vmr-codeflow-status/scripts/Get-CodeflowStatus.ps1 (PowerShell)

Code before:
    $fwdPRs = @()
    if ($LASTEXITCODE -eq 0 -and $fwdPRsJson) {
        try { $fwdPRs = ($fwdPRsJson -join "`n") | ConvertFrom-Json } catch { $fwdPRs = @() }
    }
    # Filter to exact repo match (avoid dotnet/sdk matching dotnet/sdk-container-builds)
    $fwdPRs = @($fwdPRs | Where-Object { $_.title -match "from dotnet/$([regex]::Escape($repoShortName))$" })

    $fwdHealthy = 0
    $fwdStale = 0
    $fwdConflict = 0

    if ($fwdPRs.Count -eq 0) {
        Write-Host "  No open forward flow PRs found" -ForegroundColor DarkGray
    }
    else {
        foreach ($fpr in $fwdPRs) {
            $fprBranch = if ($fpr.title -match '^\[([^\]]+)\]') { $Matches[1] } else { "unknown" }
            if ($Branch -and $fprBranch -ne $Branch) { continue }

            # Get PR details for staleness/conflict check
            $fprDetailJson = gh pr view $fpr.number -R dotnet/dotnet --json body,comments,updatedAt 2>&1
            if ($LASTEXITCODE -ne 0) {
                Write-Host "  PR #$($fpr.number) [$fprBranch]: ⚠️  Could not fetch details" -ForegroundColor Yellow
                continue
            }
            $fprDetail = ($fprDetailJson -join "`n") | ConvertFrom-Json

            # Check for staleness warnings and conflicts in comments
            $hasStaleness = $false
            $hasConflict = $false
            if ($fprDetail.comments) {
                foreach ($comment in $fprDetail.comments) {
                    if ($comment.author.login -match '^dotnet-maestro') {
                        if ($comment.body -match 'codeflow cannot continue|the source repository has received code changes') { $hasStaleness = $true }
                        if ($comment.body -match 'Conflict detected') { $hasConflict = $true }
                    }
                }
            }

            $status = "✅ Healthy"
            $color = "Green"
            if ($hasConflict) {
                $status = "🔴 Conflict"
                $color = "Red"
                $fwdConflict++
            }
            elseif ($hasStaleness) {
                $status = "⚠️  Stale"
                $color = "Yellow"
                $fwdStale++
            }

Review comment (bug):
`ConvertFrom-Json` on PR details isn't guarded by a `try/catch` here, so any non-JSON output (or CLI formatting changes) will throw and abort the script due to `$ErrorActionPreference = 'Stop'`. Wrap the JSON parse in `try/catch` (like other `gh search` parsing in this script) and treat failures as a non-fatal 'could not fetch/parse details' state.
```suggestion
            $fprDetailRaw = $fprDetailJson -join "`n"
            try {
                $fprDetail = $fprDetailRaw | ConvertFrom-Json
            }
            catch {
                Write-Host "  PR #$($fpr.number) [$fprBranch]: ⚠️  Could not parse details JSON" -ForegroundColor Yellow
                continue
            }
```

Code after:
    # --- Forward flow: check PRs from this repo into the VMR ---
    $repoShortName = $Repository -replace '^dotnet/', ''
    Write-Host ""
    Write-Section "Forward flow PRs ($Repository → dotnet/dotnet)"

    $fwdPRsJson = gh search prs --repo dotnet/dotnet --author "dotnet-maestro[bot]" --state open "Source code updates from dotnet/$repoShortName" --json number,title --limit 10 2>$null
    $fwdPRs = @()
    if ($LASTEXITCODE -eq 0 -and $fwdPRsJson) {
        try { $fwdPRs = ($fwdPRsJson -join "`n") | ConvertFrom-Json } catch { $fwdPRs = @() }
    }
    # Filter to exact repo match (avoid dotnet/sdk matching dotnet/sdk-container-builds)
    $fwdPRs = @($fwdPRs | Where-Object { $_.title -match "from dotnet/$([regex]::Escape($repoShortName))$" })

    $fwdHealthy = 0
    $fwdStale = 0
    $fwdConflict = 0

    if ($fwdPRs.Count -eq 0) {
        Write-Host "  No open forward flow PRs found" -ForegroundColor DarkGray
    }
    else {
        foreach ($fpr in $fwdPRs) {
            $fprBranch = if ($fpr.title -match '^\[([^\]]+)\]') { $Matches[1] } else { "unknown" }
            if ($Branch -and $fprBranch -ne $Branch) { continue }

            # Get PR details for staleness/conflict check
            $fprDetailJson = gh pr view $fpr.number -R dotnet/dotnet --json body,comments,updatedAt 2>$null
            if ($LASTEXITCODE -ne 0) {
                Write-Host "  PR #$($fpr.number) [$fprBranch]: ⚠️  Could not fetch details" -ForegroundColor Yellow
                continue
            }
            try {
                $fprDetail = ($fprDetailJson -join "`n") | ConvertFrom-Json
            }
            catch {
                Write-Host "  PR #$($fpr.number) [$fprBranch]: ⚠️  Could not parse details" -ForegroundColor Yellow
                continue
            }

            # Check for staleness warnings and conflicts in comments
            $hasStaleness = $false
            $hasConflict = $false
            if ($fprDetail.comments) {
                foreach ($comment in $fprDetail.comments) {
                    if ($comment.author.login -match '^dotnet-maestro') {
                        if ($comment.body -match 'codeflow cannot continue|the source repository has received code changes') { $hasStaleness = $true }
                        if ($comment.body -match 'Conflict detected') { $hasConflict = $true }
                    }
                }
            }