Error when saving scripts

When I am editing scripts, and saving them, get this message:

Message reads:

An error occured. Object reference not set to an instance of an object.
at UniversalAutomation.PowerShellSerializer1.Serialize(IEnumerable1 items) in C:\actions-runner_work\universal\universal\src\Universal.Server\Services\PowerShellSerializer.cs:line 486 at UniversalAutomation.PowerShellSerializer1.SerializeToFileAsync(IEnumerable1 models) in C:\actions-runner_work\universal\universal\src\Universal.Server\Services\PowerShellSerializer.cs:line 91 at UniversalAutomation.Services.ScriptService.SerializeScriptsAsync() in C:\actions-runner_work\universal\universal\src\Universal.Server\Services\Configuration\Scripts.cs:line 245 at UniversalAutomation.Services.ScriptService.UpdateAsync(ModelOperationContext1 context) in C:\actions-runner\_work\universal\universal\src\Universal.Server\Services\Configuration\Scripts.cs:line 237 at UniversalAutomation.Services.UniversalConfigurationService.WriteAndSyncAsync[T](T item, Identity identity) in C:\actions-runner\_work\universal\universal\src\Universal.Server\Services\UniversalConfigurationService.cs:line 82 at PowerShellUniversal.Shared.ResourceCodeEditor1.Save(StandaloneCodeEditor editor) in C:\actions-runner_work\universal\universal\src\Universal.Server\Shared\ResourceCodeEditor.razor:line 318 at PowerShellUniversal.Shared.ResourceCodeEditor`1.Save() in C:\actions-runner_work\universal\universal\src\Universal.Server\Shared\ResourceCodeEditor.razor:line 270 at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task) at AntDesign.Button.HandleOnClick(MouseEventArgs args) at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task) at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)

(this is a new installation, only a few weeks old deployment on a Windows Server 2019 instance…)

  • it seems to affect any scripts
  • script saves despite the message (so it is not a show-stopper for now)
  • but makes other colleagues concerned
Product: PowerShell Universal
Version: 5.2.0

I’ll make sure to get some error handling integrated here. I don’t exactly see what is causing this but do so, based on the stack trace, how a null reference could happen.

To be fair it seems restarting the PSU service fixes it, but given that this was something happening on the previous instance too, it might surface from time to time (if it happens again I try to get more details).