Skip to content

Commit

Permalink
TryConvertFromXml: Prevent NRE when NormalizedVersion is missing (#1503)
Browse files Browse the repository at this point in the history
  • Loading branch information
sean-r-williams authored and alerickson committed Feb 5, 2024
1 parent 47d83b3 commit 7c35222
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/code/PSResourceInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,11 @@ public static bool TryConvertFromXml(
};

var additionalMetadataHashtable = new Dictionary<string, string>();
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);

Expand Down

0 comments on commit 7c35222

Please sign in to comment.