2026.3.4 - Endpoints Throwing Unexplained Exceptions

2026.3.4 - Endpoints Throwing Unexplained Exceptions

avatar

PSU: 2026.3.4

OS: Windows Server 2025

Hosting: IIS

I'm not sure what the best way to provide instructions on how to reproduce this; however, I have an API that worked fine in 2026.3.3, but in 2026.3.4, when I run it using the following regex definition, I get the following error:

URL = 'my/api/v1/Virtualization/Cluster/(?<VirtualizationClusterId>[0-9]+)/vLAN'; Method = @('POST'); Environment = 'Dedicated - API - v1'; Description = "APIv1 - Create new vLANs for the specified virtualization Cluster."; Regex = $True; Authentication = $True; Role = @('Administrator','PSUService')

Exception of type 'PowerShellUniversal.ApiResponseException' was thrown.
at ScriptBlock, D:\Powershell Universal\Repository\Scripts\vLANs.ps1: line 24
at ScriptBlock, No file: line 1

If I use the same script, but with the following definition (without regex), it works without error:

URL = 'my/api/v1/Virtualization/Cluster/:VirtualizationClusterId/vLAN'; Method = @('POST'); Environment = 'Dedicated - API - v1'; Description = "APIv1 - Create new vLANs for the specified virtualization Cluster."; Authentication = $True; Role = @('Administrator','PSUService')

For note, line 24 is the first line of the Param block, with the following:

[Parameter(Mandatory=$True,ParameterSetName='Post')]

I've also got another endpoint that worked in 2026.3.3, but after upgrading to 2026.3.4, I now get errors on (regex configured or not). I configured transcription for the whole script, which doesn't catch an error (makes it to the end of the script), but PSU returns the following error: "Object reference not set to an instance of an object"

[11/3/2026 4:59:52 PM] [Error] [Api-/my/api/v1/Computer/Request:POST|PATCH|DELETE] System.NullReferenceException: Object reference not set to an instance of an object.
   at UniversalAutomation.Host.PowerShellApiService.ExecuteRequest(ApiRequest request) in D:\a\powershell-universal\powershell-universal\src\Host\ApiService.cs:line 295
   at UniversalAutomation.Host.PowerShellApiService.ExecuteRequest(ApiRequest request) in D:\a\powershell-universal\powershell-universal\src\Host\ApiService.cs:line 295

I'm not sure what else I can provide to help further troubleshoot these.

All Comments (1)

avatar

Hello Jacob,

Thank you for the details. In our lab on 2026.3.3 and 2026.3.4, we reproduced the "Object reference" error, but not your ApiResponseException with its generic message.

The "Object reference not set to an instance of an object" error comes after your script ends, when PowerShell Universal builds the response. It happens when the endpoint outputs more than one object and the first one is $null. In our lab, a $null or a missing hashtable key written before the real result gave exactly your error, on 2026.3.3 as well as on 2026.3.4.

One change in 2026.3.4 is $ClaimsPrincipal. In 2026.3.3 an endpoint received it as JSON text, and in 2026.3.4 it is an object you read directly, for example $ClaimsPrincipal.Identity.Name. A script that still runs $ClaimsPrincipal | ConvertFrom-Json now fails with "Conversion from JSON failed". In our lab, when a try/catch caught that error, the value read from it was $null, and that $null, output first, gave your error on 2026.3.4 while the same script worked on 2026.3.3.

If your Computer/Request script reads $ClaimsPrincipal with ConvertFrom-Json, read the object directly instead. If it does not, look for a command in it that writes $null before your result.

For the vLAN endpoint, ApiResponseException is raised by Invoke-PSUEndpoint when the endpoint it calls answers with an error. Its message is the body of that answer, so the generic "Exception of type ... was thrown" message means the called endpoint answered with an error and no body. In our lab, your regex definition with the Mandatory parameter in the Post set worked through Invoke-PSUEndpoint on both versions.

To find the call that fails, please send us these four things.

1. The param block of vLANs.ps1.

2. Every Invoke-PSUEndpoint call vLANs.ps1 makes, directly or through a function, with its URL, and which one raised the exception, with the response status if you have it.

3. Whether vLANs.ps1 or the Computer/Request script reads $ClaimsPrincipal.

4. How you call Computer/Request, over HTTP or with Invoke-PSUEndpoint.

I am also reporting to our development team that a $null first output makes the response fail instead of being returned, and I will let you know what comes of it.

Best regards,

Michel

Michel Audi