From 7500924304ee442ccc5ee9ddb9ccd62d863c0bf7 Mon Sep 17 00:00:00 2001 From: Luke Hagar Date: Thu, 5 Mar 2026 11:56:04 -0600 Subject: [PATCH] Fix 12 bugs across hand-written files, templates, and build scripts - Fix C-style // comment causing runtime error in api_client template - Fix inverted anyOf match condition breaking all anyOf deserialization - Fix Get-Config returning undefined local variable instead of Script scope - Fix URL validation regex character class to proper protocol match - Fix inability to set falsy values for Experimental, retry params - Fix proxy being cleared unconditionally when not passed - Fix same regex bug in configuration template - Fix undefined Function variable in PaginateSearch error handler - Add Function parameter to Invoke-PaginateSearch for non-V3 search APIs - Fix Get-Accounts -> Get-BetaAccounts in Beta test block - Remove trailing comma in JSON test fixture - Replace broken fs.stat() check with fs.mkdir({ recursive: true }) Co-Authored-By: Claude Opus 4.6 --- PSSailpoint/Configuration.ps1 | 12 ++++++------ PSSailpoint/Pagination.ps1 | 6 ++++-- PSSailpoint/tests/Validation.Tests.ps1 | 4 ++-- sdk-resources/postscript.js | 4 +--- sdk-resources/resources/api_client.mustache | 2 +- sdk-resources/resources/configuration.mustache | 2 +- sdk-resources/resources/model_anyof.mustache | 2 +- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/PSSailpoint/Configuration.ps1 b/PSSailpoint/Configuration.ps1 index fd38a6dd1..38721eff4 100644 --- a/PSSailpoint/Configuration.ps1 +++ b/PSSailpoint/Configuration.ps1 @@ -146,7 +146,7 @@ function Set-DefaultConfiguration { If ($BaseUrl) { # validate URL $URL = $BaseUrl -as [System.URI] - if (!($null -ne $URL.AbsoluteURI -and $URL.Scheme -match '[http|https]')) { + if (!($null -ne $URL.AbsoluteURI -and $URL.Scheme -match '^https?$')) { throw "Invalid URL '$($BaseUrl)' cannot be used in the base URL." } $Script:Configuration["BaseUrl"] = $BaseUrl @@ -172,15 +172,15 @@ function Set-DefaultConfiguration { $Script:Configuration['ClientSecret'] = $ClientSecret } - If ($RetryIntervalSeconds) { + If ($PSBoundParameters.ContainsKey('RetryIntervalSeconds')) { $Script:Configuration['RetryIntervalSeconds'] = $RetryIntervalSeconds } - If ($MaximumRetryCount) { + If ($PSBoundParameters.ContainsKey('MaximumRetryCount')) { $Script:Configuration['MaximumRetryCount'] = $MaximumRetryCount } - If ($Experimental) { + If ($PSBoundParameters.ContainsKey('Experimental')) { $Script:Configuration['Experimental'] = $Experimental } @@ -189,7 +189,7 @@ function Set-DefaultConfiguration { throw "Incorrect Proxy type '$($Proxy.GetType().FullName)'. Must be System.Net.WebProxy or System.Net.SystemWebProxy or System.Net.WebRequest+WebProxyWrapperOpaque." } $Script:Configuration['Proxy'] = $Proxy - } else { + } elseif ($PSBoundParameters.ContainsKey('Proxy')) { $Script:Configuration['Proxy'] = $null } @@ -321,5 +321,5 @@ function Get-Config { return $LocalConfig } - return $Configuration + return $Script:Configuration } diff --git a/PSSailpoint/Pagination.ps1 b/PSSailpoint/Pagination.ps1 index 5883b7e9a..339405847 100644 --- a/PSSailpoint/Pagination.ps1 +++ b/PSSailpoint/Pagination.ps1 @@ -71,10 +71,12 @@ function Invoke-PaginateSearch { Param( [Parameter(Mandatory = $false)] [ValidateNotNull()] - [ValidateScript({ ($_.sort | Measure-Object).Count -eq 1 }, + [ValidateScript({ ($_.sort | Measure-Object).Count -eq 1 }, ErrorMessage = "Error! The required `Search` parameter must include exactly one sort parameter to paginate properly.")] [PSCustomObject] $Search, + [Parameter(Mandatory = $false)] + [string]$Function = "Search-Post", [Int32]$Increment = 250, [Int32]$Limit = 10000, [Switch]$WithHttpInfo @@ -101,7 +103,7 @@ function Invoke-PaginateSearch { Write-Debug "SearchAfter=$SearchAfter" } - $Result = Search-Post -Limit $Increment -Search $Search -WithHttpInfo + $Result = & $Function -Limit $Increment -Search $Search -WithHttpInfo Write-Debug "Retrieved $(($Result.Response | Measure-Object).Count) Results" diff --git a/PSSailpoint/tests/Validation.Tests.ps1 b/PSSailpoint/tests/Validation.Tests.ps1 index 03bd59698..2d1a315f4 100644 --- a/PSSailpoint/tests/Validation.Tests.ps1 +++ b/PSSailpoint/tests/Validation.Tests.ps1 @@ -21,7 +21,7 @@ Describe 'V3' { "identities" ], "query": { - "query": "*", + "query": "*" }, "sort": ["-name"] } @@ -46,7 +46,7 @@ Describe 'V3' { Describe 'Beta' { It 'Returns results for Get-BetaAccounts' { - $Response = Get-Accounts -WithHttpInfo + $Response = Get-BetaAccounts -WithHttpInfo $Response.Response | Should -Not -BeNullOrEmpty $Response.StatusCode | Should -Be 200 diff --git a/sdk-resources/postscript.js b/sdk-resources/postscript.js index 0e56eacd1..eebf6bace 100644 --- a/sdk-resources/postscript.js +++ b/sdk-resources/postscript.js @@ -67,9 +67,7 @@ const createDir = async (srcDir, dirName) => { const moveFiles = async (srcPath, destPath, filename = null) => { try { - if (!await fs.stat(destPath)) { - await fs.mkdir(destPath, { recursive: true }); - } + await fs.mkdir(destPath, { recursive: true }); if (filename) { const filePath = path.join(srcPath, filename); diff --git a/sdk-resources/resources/api_client.mustache b/sdk-resources/resources/api_client.mustache index 7fdd0c7a7..4838e0976 100644 --- a/sdk-resources/resources/api_client.mustache +++ b/sdk-resources/resources/api_client.mustache @@ -104,7 +104,7 @@ function Invoke-{{{apiNamePrefix}}}ApiClient { # construct URL query string $HttpValues = [System.Web.HttpUtility]::ParseQueryString([String]::Empty) foreach ($Parameter in $QueryParameters.GetEnumerator()) { - if ($Parameter.Value.Count -gt 1) { // array + if ($Parameter.Value.Count -gt 1) { # array foreach ($Value in $Parameter.Value) { $HttpValues.Add($Parameter.Key + '[]', $Value) } diff --git a/sdk-resources/resources/configuration.mustache b/sdk-resources/resources/configuration.mustache index ffc9ca50d..a7e3dde0a 100644 --- a/sdk-resources/resources/configuration.mustache +++ b/sdk-resources/resources/configuration.mustache @@ -132,7 +132,7 @@ function Set-{{{apiNamePrefix}}}Configuration { If ($BaseUrl) { # validate URL $URL = $BaseUrl -as [System.URI] - if (!($null -ne $URL.AbsoluteURI -and $URL.Scheme -match '[http|https]')) { + if (!($null -ne $URL.AbsoluteURI -and $URL.Scheme -match '^https?$')) { throw "Invalid URL '$($BaseUrl)' cannot be used in the base URL." } $Script:Configuration["BaseUrl"] = $BaseUrl diff --git a/sdk-resources/resources/model_anyof.mustache b/sdk-resources/resources/model_anyof.mustache index 1021ad5c8..78ba300a4 100644 --- a/sdk-resources/resources/model_anyof.mustache +++ b/sdk-resources/resources/model_anyof.mustache @@ -68,7 +68,7 @@ function ConvertFrom-{{{apiNamePrefix}}}JsonTo{{{classname}}} { {{/mappedModels}} {{/discriminator}} {{#anyOf}} - if ($match -ne 0) { # no match yet + if ($match -eq 0) { # no match yet # try to match {{{.}}} defined in the anyOf schemas try { $matchInstance = ConvertFrom-{{{apiNamePrefix}}}JsonTo{{{.}}} $Json