@@ -72,7 +72,7 @@ function Invoke-GitHubApi {
7272 $args += ' -H'
7373 $args += ' Accept: application/vnd.github.raw'
7474 }
75- $result = gh api @args 2>&1
75+ $result = gh api @args 2> $null
7676 if ($LASTEXITCODE -ne 0 ) {
7777 Write-Warning " GitHub API call failed: $Endpoint "
7878 return $null
@@ -186,12 +186,18 @@ if ($CheckMissing) {
186186 }
187187
188188 # Get the PR body to extract VMR commit and VMR branch
189- $prDetailJson = gh pr view $lastPR.number - R $Repository -- json body 2>&1
189+ $prDetailJson = gh pr view $lastPR.number - R $Repository -- json body 2> $null
190190 if ($LASTEXITCODE -ne 0 ) {
191191 Write-Host " ⚠️ Could not fetch PR #$ ( $lastPR.number ) details" - ForegroundColor Yellow
192192 continue
193193 }
194- $prDetail = ($prDetailJson -join " `n " ) | ConvertFrom-Json
194+ try {
195+ $prDetail = ($prDetailJson -join " `n " ) | ConvertFrom-Json
196+ }
197+ catch {
198+ Write-Host " ⚠️ Could not parse PR #$ ( $lastPR.number ) details" - ForegroundColor Yellow
199+ continue
200+ }
195201
196202 $vmrCommitFromPR = $null
197203 $vmrBranchFromPR = $null
@@ -286,12 +292,18 @@ if ($CheckMissing) {
286292 if ($Branch -and $fprBranch -ne $Branch ) { continue }
287293
288294 # Get PR details for staleness/conflict check
289- $fprDetailJson = gh pr view $fpr.number - R dotnet/ dotnet -- json body, comments, updatedAt 2>&1
295+ $fprDetailJson = gh pr view $fpr.number - R dotnet/ dotnet -- json body, comments, updatedAt 2> $null
290296 if ($LASTEXITCODE -ne 0 ) {
291297 Write-Host " PR #$ ( $fpr.number ) [$fprBranch ]: ⚠️ Could not fetch details" - ForegroundColor Yellow
292298 continue
293299 }
294- $fprDetail = ($fprDetailJson -join " `n " ) | ConvertFrom-Json
300+ try {
301+ $fprDetail = ($fprDetailJson -join " `n " ) | ConvertFrom-Json
302+ }
303+ catch {
304+ Write-Host " PR #$ ( $fpr.number ) [$fprBranch ]: ⚠️ Could not parse details" - ForegroundColor Yellow
305+ continue
306+ }
295307
296308 # Check for staleness warnings and conflicts in comments
297309 $hasStaleness = $false
@@ -498,7 +510,7 @@ if (-not $isForwardFlow) {
498510 }
499511 catch {
500512 # Fall back to regex if XML parsing fails
501- if ($vdContent -match ' <Source\s+[^>]*Sha="([a-fA-F0-9]+ )"' ) {
513+ if ($vdContent -match ' <Source\s+[^>]*Sha="([a-fA-F0-9]{40} )"' ) {
502514 $versionDetailsVmrCommit = $Matches [1 ]
503515 $branchVmrCommit = $versionDetailsVmrCommit
504516 }
@@ -534,7 +546,7 @@ if ($branchVmrCommit -or $vmrCommit) {
534546
535547 if ($vmrCommit ) {
536548 $bodyShort = Get-ShortSha $vmrCommit
537- if ($vmrCommit.StartsWith ($branchVmrCommit ) -or $branchVmrCommit.StartsWith ($vmrCommit )) {
549+ if ($vmrCommit.StartsWith ($branchVmrCommit , [ StringComparison ]::OrdinalIgnoreCase ) -or $branchVmrCommit.StartsWith ($vmrCommit , [ StringComparison ]::OrdinalIgnoreCase )) {
538550 Write-Host " ✅ $sourceLabel ($branchShort ) matches PR body ($bodyShort )" - ForegroundColor Green
539551 }
540552 else {
0 commit comments