Skip to content

Commit 10012b4

Browse files
committed
more audit log error handling
1 parent 9ece8de commit 10012b4

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

Modules/CIPPCore/Public/AuditLogs/New-CippAuditLogSearch.ps1

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,19 @@ function New-CippAuditLogSearch {
190190
}
191191
}
192192

193+
# Handle HTML error pages (e.g. Azure Front Door 502/504 gateway timeouts)
194+
if ($TrimmedAuditLogErrorMessage -match '<!DOCTYPE|<html' -and $TrimmedAuditLogErrorMessage -match '<title>([^<]+)</title>') {
195+
$HtmlTitle = $Matches[1].Trim()
196+
Write-LogMessage -API 'Audit Logs' -tenant $TenantFilter -message "Audit log search creation failed with gateway error for tenant $TenantFilter ($HtmlTitle) - will retry next cycle" -sev Warning
197+
return [PSCustomObject]@{
198+
id = $null
199+
displayName = [string]$DisplayName
200+
status = [string]'GatewayError'
201+
cippStatus = [string]'TransientError'
202+
message = [string]"Microsoft returned gateway error ($HtmlTitle) - search will be retried next cycle."
203+
}
204+
}
205+
193206
# Handle Microsoft-side timeouts / transient errors (e.g. UnknownError with empty message)
194207
$ErrorCode = $AuditLogError.error.code ?? $AuditLogError.code
195208
if ($ErrorCode -in @('UnknownError', 'ServiceUnavailable', 'RequestTimeout', 'GatewayTimeout', 'TooManyRequests')) {

0 commit comments

Comments
 (0)