Skip to content

Commit aa2a8a1

Browse files
Fix 50x errors while loading page links (Azure#19301)
We have hit a few 50x errors while pulling a page to get links and that has caused the rest of the link checking to terminate early. To fix that we switching to LogError which will output an error in devops instead of Write-Error which terminates immediately. We also add some retry count to the page retrieval and cache file retrieval to help with these transitent 50x issues. Co-authored-by: Wes Haggard <Wes.Haggard@microsoft.com>
1 parent 0b825a8 commit aa2a8a1

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

eng/common/scripts/Verify-Links.ps1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
4444
.PARAMETER outputCacheFile
4545
Path to a file that the script will output all the validated links after running all checks.
46-
46+
4747
.PARAMETER requestTimeoutSec
4848
The number of seconds before we timeout when sending an individual web request. Default is 15 seconds.
4949
@@ -332,7 +332,7 @@ function GetLinks([System.Uri]$pageUri)
332332
{
333333
if ($pageUri.Scheme.StartsWith("http")) {
334334
try {
335-
$response = Invoke-WebRequest -Uri $pageUri -UserAgent $userAgent -TimeoutSec $requestTimeoutSec
335+
$response = Invoke-WebRequest -Uri $pageUri -UserAgent $userAgent -TimeoutSec $requestTimeoutSec -MaximumRetryCount 3
336336
$content = $response.Content
337337

338338
if ($pageUri.ToString().EndsWith(".md")) {
@@ -341,7 +341,7 @@ function GetLinks([System.Uri]$pageUri)
341341
}
342342
catch {
343343
$statusCode = $_.Exception.Response.StatusCode.value__
344-
Write-Error "Invalid page [$statusCode] $pageUri"
344+
LogError "Invalid page [$statusCode] $pageUri"
345345
}
346346
}
347347
elseif ($pageUri.IsFile -and (Test-Path $pageUri.LocalPath)) {
@@ -363,7 +363,7 @@ function GetLinks([System.Uri]$pageUri)
363363
}
364364
}
365365
else {
366-
Write-Error "Don't know how to process uri $pageUri"
366+
LogError "Don't know how to process uri $pageUri"
367367
}
368368

369369
$links = ParseLinks $pageUri $content
@@ -396,12 +396,12 @@ if ($inputCacheFile)
396396
$cacheContent = ""
397397
if ($inputCacheFile.StartsWith("http")) {
398398
try {
399-
$response = Invoke-WebRequest -Uri $inputCacheFile -TimeoutSec $requestTimeoutSec
399+
$response = Invoke-WebRequest -Uri $inputCacheFile -TimeoutSec $requestTimeoutSec -MaximumRetryCount 3
400400
$cacheContent = $response.Content
401401
}
402402
catch {
403403
$statusCode = $_.Exception.Response.StatusCode.value__
404-
Write-Error "Failed to read cache file from page [$statusCode] $inputCacheFile"
404+
LogError "Failed to read cache file from page [$statusCode] $inputCacheFile"
405405
}
406406
}
407407
elseif (Test-Path $inputCacheFile) {

0 commit comments

Comments
 (0)