Skip to content

Fix 12 bugs in hand-written files, templates, and build scripts#156

Open
luke-hagar-sp wants to merge 1 commit intomainfrom
fix/cross-sdk-bug-fixes
Open

Fix 12 bugs in hand-written files, templates, and build scripts#156
luke-hagar-sp wants to merge 1 commit intomainfrom
fix/cross-sdk-bug-fixes

Conversation

@luke-hagar-sp
Copy link
Contributor

@luke-hagar-sp luke-hagar-sp commented Mar 5, 2026

Summary

Cross-SDK audit identified 12 bugs in the PowerShell SDK across hand-written files, mustache templates, and build scripts. Template fixes will propagate to generated code on next make build.

Bug Fixes

Critical

PS1: C-style // comment is invalid PowerShell — causes runtime error on array query params

  • sdk-resources/resources/api_client.mustache L107: if ($Parameter.Value.Count -gt 1) { // array — PowerShell doesn't support // comments. This causes a parse error whenever an API call includes array-valued query parameters.
  • Fix: Changed // to #.

PS2: Inverted anyOf match condition breaks all anyOf deserialization

  • sdk-resources/resources/model_anyof.mustache L71: if ($match -ne 0)$match starts at 0 and increments on match. The condition -ne 0 is $false on the first iteration, so the first anyOf type is never attempted, and no subsequent types can match either.
  • Fix: Changed to if ($match -eq 0).

PS3: Get-Config returns undefined local $Configuration instead of script-scoped variable

  • PSSailpoint/Configuration.ps1 L324: return $Configuration returns an undefined local variable. When neither env nor local config succeeds, this returns $null, causing a null reference on $Configuration.BaseUrl[-1] in Get-DefaultConfiguration.
  • Fix: Changed to return $Script:Configuration.

Medium

PS4: URL validation regex '[http|https]' is a character class, not alternation

  • PSSailpoint/Configuration.ps1 L149: [http|https] matches individual characters h, t, p, s, | — not the strings "http" or "https". This accepts URLs with schemes like ftp, ssh, etc.
  • Fix: Changed to '^https?$'.

PS5: Cannot set $Experimental to $false, or retry values to 0

PS6: Proxy cleared unconditionally when not passed to Set-DefaultConfiguration

  • PSSailpoint/Configuration.ps1 L192-194: The else branch of the proxy check sets $Script:Configuration['Proxy'] = $null even when the user didn't pass -Proxy at all, clearing any previously configured proxy.
  • Fix: Changed else to elseif ($PSBoundParameters.ContainsKey('Proxy')).

PS7: Same regex bug as PS4 in generated configuration template

Low

PS8 + PS9: Hardcoded Search-Post and undefined $Function in Invoke-PaginateSearch

  • PSSailpoint/Pagination.ps1 L104: The search function was hardcoded to Search-Post, making it impossible to paginate Beta/V2024/V2025/V2026 search endpoints. The catch block also referenced $Function which was undefined.
  • Fix: Added an optional $Function parameter (default "Search-Post" for backward compatibility) and use & $Function to invoke it dynamically. This also resolves the undefined $Function in the error handler.

PS10: Beta test calls V3 Get-Accounts instead of Get-BetaAccounts

PS11: Trailing comma in JSON test fixture causes parse error

PS12: Broken fs.stat() check in moveFiles() in postscript.js

  • sdk-resources/postscript.js L70: Same issue as Go SDK — fs.stat() throws on missing path instead of returning falsy.
  • Fix: Replaced with await fs.mkdir(destPath, { recursive: true }).

Verification

  • Template fixes (PS1, PS2, PS7) verified by source inspection; will take effect on next make build
  • Hand-written file changes verified by syntax inspection

Test plan

  • Run Import-Module ./PSSailpoint/PSSailpoint.psm1 to verify module loads
  • Test API call with array query parameters to verify PS1 fix
  • Test anyOf deserialization (e.g., a model using anyOf schemas) to verify PS2 fix
  • Run Invoke-Pester to verify test fixes (PS10, PS11)
  • Test Set-DefaultConfiguration -Experimental $false to verify PS5 fix
  • Test Set-DefaultConfiguration -BaseUrl "ftp://evil" is rejected by PS4 fix

🤖 Generated with Claude Code

- 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 <noreply@anthropic.com>
@luke-hagar-sp luke-hagar-sp force-pushed the fix/cross-sdk-bug-fixes branch from f2ef170 to 7500924 Compare March 5, 2026 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant