From d27e50323c3f4ea3cb4ad7c0e2c07f1b26969038 Mon Sep 17 00:00:00 2001 From: Wes Haggard Date: Fri, 2 Feb 2024 10:29:33 -0800 Subject: [PATCH] Fix issue in Verify-Link.ps1 after PS 7.4 update https://learn.microsoft.com/en-us/powershell/scripting/whats-new/what-s-new-in-powershell-74?view=powershell-7.4 - Add AllowInsecureRedirect switch to Web cmdlets (#18546) That new option cause a new exception type that exposed a bug where we assumed if InnerException property existed that it was not null. This fix verifies that the property is not null. --- eng/common/scripts/Verify-Links.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/common/scripts/Verify-Links.ps1 b/eng/common/scripts/Verify-Links.ps1 index 62fd3df9875..396ece4ac37 100644 --- a/eng/common/scripts/Verify-Links.ps1 +++ b/eng/common/scripts/Verify-Links.ps1 @@ -260,7 +260,7 @@ function CheckLink ([System.Uri]$linkUri, $allowRetry=$true) $innerExceptionPresent = $_.Exception.psobject.Properties.name -contains "InnerException" $errorCodePresent = $false - if ($innerExceptionPresent) { + if ($innerExceptionPresent -and $_.Exception.InnerException) { $errorCodePresent = $_.Exception.InnerException.psobject.Properties.name -contains "ErrorCode" }