Summary
File: src/functions/secrets/Search-TssSecret.ps1:277-298
The 0.62.1 always-array contract emits [Thycotic.PowerShell.Secrets.Summary[]]@() from the else branch when \$restResponse.records is falsy. That branch is reached in two cases:
- The API returned successfully with zero records.
- The API call threw (caught at line 280) and
\$restResponse is \$null.
A caller assigning \[Summary[]\] \$x = Search-TssSecret … receives an empty typed array in both cases and cannot tell which happened. A Write-Warning 'Issue on search request' is emitted in the catch, so a caller using -WarningAction Stop or checking the warning stream is protected — but a caller relying on the result value alone will silently treat an API failure as "no matches."
Proposed fix
Either:
- On the catch (line 280-284),
return after . $ErrorHandling $err so no output is emitted, OR
- Set a
\$hadError flag on catch and skip the else-branch emission on error.
Prefer the second so -ErrorAction Continue callers still see the warning without also getting a misleading empty-array value.
Discovery
Consolidated PR review of v0.62.0 → dev (0.62.1 candidate). Direct consequence of the #459 always-array contract (PR #460); the pre-0.62.1 behavior returned \$null on error, which was equally ambiguous but at least distinguishable by type check.
Summary
File:
src/functions/secrets/Search-TssSecret.ps1:277-298The 0.62.1 always-array contract emits
[Thycotic.PowerShell.Secrets.Summary[]]@()from theelsebranch when\$restResponse.recordsis falsy. That branch is reached in two cases:\$restResponseis\$null.A caller assigning
\[Summary[]\] \$x = Search-TssSecret …receives an empty typed array in both cases and cannot tell which happened. AWrite-Warning 'Issue on search request'is emitted in the catch, so a caller using-WarningAction Stopor checking the warning stream is protected — but a caller relying on the result value alone will silently treat an API failure as "no matches."Proposed fix
Either:
returnafter. $ErrorHandling $errso no output is emitted, OR\$hadErrorflag on catch and skip the else-branch emission on error.Prefer the second so
-ErrorAction Continuecallers still see the warning without also getting a misleading empty-array value.Discovery
Consolidated PR review of v0.62.0 → dev (0.62.1 candidate). Direct consequence of the #459 always-array contract (PR #460); the pre-0.62.1 behavior returned
\$nullon error, which was equally ambiguous but at least distinguishable by type check.