mirror of
https://github.com/GoodOlClint/PSProxmoxVE.git
synced 2026-07-26 07:58:14 +00:00
fix: address second round of Copilot review feedback
- Replace null-forgiving operator on Marshal.PtrToStringUni with null-coalescing fallback (AddPveClusterMemberCmdlet.cs:64) - GetNextId now throws InvalidOperationException instead of silently returning 0 when API response cannot be parsed Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -396,10 +396,11 @@ namespace PSProxmoxVE.Core.Services
|
|||||||
{
|
{
|
||||||
var response = client.GetAsync(resource).GetAwaiter().GetResult();
|
var response = client.GetAsync(resource).GetAwaiter().GetResult();
|
||||||
var data = JObject.Parse(response)["data"];
|
var data = JObject.Parse(response)["data"];
|
||||||
// The API returns the ID as a string, parse it to int
|
if (data == null)
|
||||||
if (data != null && int.TryParse(data.ToString(), out var id))
|
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 id;
|
||||||
return 0;
|
throw new InvalidOperationException($"API returned unexpected next VMID value: '{data}'");
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ namespace PSProxmoxVE.Cmdlets.Cluster
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
ptr = Marshal.SecureStringToGlobalAllocUnicode(Password);
|
ptr = Marshal.SecureStringToGlobalAllocUnicode(Password);
|
||||||
var plainPassword = Marshal.PtrToStringUni(ptr)!;
|
var plainPassword = Marshal.PtrToStringUni(ptr) ?? string.Empty;
|
||||||
|
|
||||||
var linkDict = ParseLinks(Links);
|
var linkDict = ParseLinks(Links);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user