From b7b761346eded62cbc3638b88bcef1ab4dcea226 Mon Sep 17 00:00:00 2001 From: "Sean R. Williams" Date: Tue, 2 Jan 2024 19:20:43 -0800 Subject: [PATCH] TryConvertFromXml: Prevent NRE when NormalizedVersion is missing --- src/code/PSResourceInfo.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/code/PSResourceInfo.cs b/src/code/PSResourceInfo.cs index 643833640..50bcb6360 100644 --- a/src/code/PSResourceInfo.cs +++ b/src/code/PSResourceInfo.cs @@ -571,7 +571,11 @@ public static bool TryConvertFromXml( }; var additionalMetadataHashtable = new Dictionary(); - additionalMetadataHashtable.Add("NormalizedVersion", metadata["NormalizedVersion"].ToString()); + + // Only add NormalizedVersion to additionalMetadata if server response included it + if (metadata.ContainsKey("NormalizedVersion")) { + additionalMetadataHashtable.Add("NormalizedVersion", metadata["NormalizedVersion"].ToString()); + } var includes = new ResourceIncludes(resourceHashtable);