Skip to content

Commit fbff091

Browse files
authored
Merge pull request #958 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents da63b45 + 85e3a88 commit fbff091

14 files changed

Lines changed: 54 additions & 9 deletions
File renamed without changes.

Modules/CIPPCore/Public/Assert-CippVersion.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ function Assert-CippVersion {
1111
1212
#>
1313
param($CIPPVersion)
14-
$APIVersion = (Get-Content -Path (Join-Path $env:CIPPRootPath 'version_latest.txt')).trim()
14+
$APIVersion = (Get-Content -Path (Join-Path $env:CIPPRootPath 'Config\version_latest.txt')).trim()
1515

16-
$RemoteAPIVersion = (Invoke-CIPPRestMethod -Uri 'https://raw.githubusercontent.com/KelvinTegelaar/CIPP-API/master/version_latest.txt').trim()
16+
$RemoteAPIVersion = (Invoke-CIPPRestMethod -Uri 'https://raw.githubusercontent.com/KelvinTegelaar/CIPP-API/master/Config/version_latest.txt').trim()
1717
$RemoteCIPPVersion = (Invoke-CIPPRestMethod -Uri 'https://raw.githubusercontent.com/KelvinTegelaar/CIPP/main/public/version.json').version
1818

1919
[PSCustomObject]@{

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,33 @@ function New-CippAuditLogSearch {
189189
message = [string]'Unified auditing is disabled for this tenant.'
190190
}
191191
}
192+
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+
206+
# Handle Microsoft-side timeouts / transient errors (e.g. UnknownError with empty message)
207+
$ErrorCode = $AuditLogError.error.code ?? $AuditLogError.code
208+
if ($ErrorCode -in @('UnknownError', 'ServiceUnavailable', 'RequestTimeout', 'GatewayTimeout', 'TooManyRequests')) {
209+
Write-LogMessage -API 'Audit Logs' -tenant $TenantFilter -message "Audit log search creation failed with transient error for tenant $TenantFilter ($ErrorCode) - will retry next cycle" -sev Warning
210+
return [PSCustomObject]@{
211+
id = $null
212+
displayName = [string]$DisplayName
213+
status = [string]$ErrorCode
214+
cippStatus = [string]'TransientError'
215+
message = [string]"Microsoft returned $ErrorCode - search will be retried next cycle."
216+
}
217+
}
218+
192219
throw
193220
}
194221

Modules/CIPPCore/Public/Authentication/Get-CippAllowedPermissions.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function Get-CippAllowedPermissions {
2323

2424
# Get all available permissions and base roles configuration
2525

26-
$Version = (Get-Content -Path (Join-Path $env:CIPPRootPath 'version_latest.txt')).trim()
26+
$Version = (Get-Content -Path (Join-Path $env:CIPPRootPath 'Config\version_latest.txt')).trim()
2727
$BaseRoles = Get-Content -Path (Join-Path $env:CIPPRootPath 'Config\cipp-roles.json') | ConvertFrom-Json
2828
$DefaultRoles = @('superadmin', 'admin', 'editor', 'readonly', 'anonymous', 'authenticated')
2929

Modules/CIPPCore/Public/Compare-CIPPIntuneObject.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ function Compare-CIPPIntuneObject {
362362
return $null
363363
}
364364
} else {
365-
$intuneCollection = Get-Content .\intuneCollection.json | ConvertFrom-Json -ErrorAction SilentlyContinue
365+
$intuneCollection = Get-Content "$env:CIPPRootPath\Config\intuneCollection.json" | ConvertFrom-Json -ErrorAction SilentlyContinue
366366
# Build a hashtable index for O(1) lookups instead of O(n) Where-Object scans
367367
$intuneCollectionIndex = @{}
368368
foreach ($item in $intuneCollection) {

Modules/CIPPCore/Public/Entrypoints/Orchestrator Functions/Start-CIPPOrchestrator.ps1

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,24 @@ function Start-CIPPOrchestrator {
3737
# ─── CIPPNG runtime: push batch directly to OrchestratorService ───
3838
if ($env:CIPPNG -eq 'true' -and $InputObject) {
3939
$OrchestratorName = $InputObject.OrchestratorName ?? 'UnnamedOrchestrator'
40+
41+
# QueueFunction pattern: call the function first to generate batch items
42+
if (-not $InputObject.Batch -and $InputObject.QueueFunction) {
43+
$QueueFuncName = "Push-$($InputObject.QueueFunction.FunctionName)"
44+
Write-Information "CIPP-NG: Calling QueueFunction '$QueueFuncName' to build batch for '$OrchestratorName'"
45+
$QueueItem = [PSCustomObject]@{}
46+
if ($InputObject.QueueFunction.Parameters) {
47+
$QueueItem = [PSCustomObject]$InputObject.QueueFunction.Parameters
48+
}
49+
$BatchResult = & $QueueFuncName -Item $QueueItem
50+
$QueueBatch = @($BatchResult | Where-Object { $null -ne $_ })
51+
if ($QueueBatch.Count -eq 0) {
52+
Write-Information "CIPP-NG: QueueFunction '$QueueFuncName' returned 0 tasks for '$OrchestratorName' - skipping"
53+
return "CIPPNG-$OrchestratorName-NoTasks"
54+
}
55+
$InputObject | Add-Member -MemberType NoteProperty -Name 'Batch' -Value $QueueBatch -Force
56+
}
57+
4058
$BatchJson = ConvertTo-Json -InputObject @($InputObject.Batch) -Depth 10 -Compress
4159

4260
$PostExecFunctionName = $null

Modules/CIPPCore/Public/Entrypoints/Timer Functions/Start-CIPPStatsTimer.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function Start-CIPPStatsTimer {
1515
$TenantCount = (Get-Tenants -IncludeAll).count
1616

1717

18-
$APIVersion = Get-Content (Join-Path $env:CIPPRootPath 'version_latest.txt') | Out-String
18+
$APIVersion = Get-Content (Join-Path $env:CIPPRootPath 'Config\version_latest.txt') | Out-String
1919
$Table = Get-CIPPTable -TableName Extensionsconfig
2020
try {
2121
$RawExt = (Get-CIPPAzDataTableEntity @Table).config | ConvertFrom-Json -Depth 10 -ErrorAction Stop

0 commit comments

Comments
 (0)