diff --git a/src/PSProxmoxVE.Core/Services/ClusterConfigService.cs b/src/PSProxmoxVE.Core/Services/ClusterConfigService.cs index 8eaa47f..e780bde 100644 --- a/src/PSProxmoxVE.Core/Services/ClusterConfigService.cs +++ b/src/PSProxmoxVE.Core/Services/ClusterConfigService.cs @@ -396,10 +396,11 @@ namespace PSProxmoxVE.Core.Services { var response = client.GetAsync(resource).GetAwaiter().GetResult(); var data = JObject.Parse(response)["data"]; - // The API returns the ID as a string, parse it to int - if (data != null && int.TryParse(data.ToString(), out var id)) + if (data == null) + throw new InvalidOperationException("API response for next VMID did not contain a 'data' field."); + if (int.TryParse(data.ToString(), out var id)) return id; - return 0; + throw new InvalidOperationException($"API returned unexpected next VMID value: '{data}'"); } finally { diff --git a/src/PSProxmoxVE/Cmdlets/Cluster/AddPveClusterMemberCmdlet.cs b/src/PSProxmoxVE/Cmdlets/Cluster/AddPveClusterMemberCmdlet.cs index 2bc7b5b..2ff938a 100644 --- a/src/PSProxmoxVE/Cmdlets/Cluster/AddPveClusterMemberCmdlet.cs +++ b/src/PSProxmoxVE/Cmdlets/Cluster/AddPveClusterMemberCmdlet.cs @@ -61,7 +61,7 @@ namespace PSProxmoxVE.Cmdlets.Cluster try { ptr = Marshal.SecureStringToGlobalAllocUnicode(Password); - var plainPassword = Marshal.PtrToStringUni(ptr)!; + var plainPassword = Marshal.PtrToStringUni(ptr) ?? string.Empty; var linkDict = ParseLinks(Links);