ironmansoftware / powershell-universal

Issue tracker for PowerShell Universal
https://powershelluniversal.com
35 stars 2 forks source link

Get-PSUJob different RunId behaviour depending on execution background #2750

Closed schubfre closed 11 months ago

schubfre commented 11 months ago

Version

3.9.17

Severity

High

Steps to Reproduce

When trying to query a non existing RunId:

Expected behaviour is from a local Powershell 5.1 or 7.1 console Actual behaviour is from a PSU API endpoint (Integrated or 5.1 or 7 doesn't matter)

Also in a try catch the $_ and $error[0] are empty. It seems like the PSU (API) environment doesn't treat it as an error, if a RunId doesn't exist, but local enviroments with the Universal module do.

Also when I do a catch [Flurl.Http.FlurlHttpException] in PSU it tells me it doesn't know the (error) class, which is very streange

Expected behavior

PS C:\Users\xxx> try {
>>     $Job = Get-PSUJob -RunId 'c7967f59-f027-41b3-a110-5ce8352afe58' -UseDefaultCredentials -Verbose -Debug -ErrorAction Stop
>>     Write 'asd'
>> } catch {
>>     Write $_.Exception.GetType().FullName
>> }
Flurl.Http.FlurlHttpException
PS C:\Users\xxx>

Actual behavior

API:
try {
    $Job = Get-PSUJob -RunId 'c7967f59-f027-41b3-a110-5ce8352afe58' -Integrated -Verbose -Debug -ErrorAction Stop
    Write-Debug 'asd'
} catch {
    Write-Debug $_.Exception.GetType().FullName
}

Log:
GET /testing ::ffff:127.0.0.1
asd
Status: 200 Content-Type: application/json Length: 2

Additional Environment data

Windows Server 2022 Kestrel LiteDB

Visuals

No response

schubfre commented 11 months ago

@adamdriscoll was this fixed in 3.9.20 too? Because I still get the same behaviour.

adamdriscoll commented 11 months ago

Sorry. We failed to merge this change into the v3 branch... It is now merged in.