From ec7854f74a50da3df88b9440b1623888414f8c20 Mon Sep 17 00:00:00 2001 From: "Brett V. Forsgren" Date: Tue, 7 Jan 2025 10:52:42 -0700 Subject: [PATCH] address review feedback --- .../NuGetUpdater.Core/Analyze/RequirementConverter.cs | 7 ++++++- .../NuGetUpdater/NuGetUpdater.Core/Clone/CloneWorker.cs | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/RequirementConverter.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/RequirementConverter.cs index 1da74d4326..ce562f7f0d 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/RequirementConverter.cs +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/RequirementConverter.cs @@ -7,10 +7,15 @@ public class RequirementConverter : JsonConverter { public override Requirement? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType != JsonTokenType.String) + { + throw new BadRequirementException($"Expected token type {nameof(JsonTokenType.String)}, but found {reader.TokenType}."); + } + var text = reader.GetString(); if (text is null) { - throw new ArgumentNullException(nameof(text)); + throw new BadRequirementException("Unexpected null token."); } try diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Clone/CloneWorker.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Clone/CloneWorker.cs index 4f48a8d477..2e4d379195 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Clone/CloneWorker.cs +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Clone/CloneWorker.cs @@ -31,6 +31,10 @@ public async Task RunAsync(FileInfo jobFilePath, DirectoryInfo repoContents try { jobFile = RunWorker.Deserialize(jobFileContent); + if (jobFile is null) + { + parseError = new UnknownError(new Exception("Job file could not be deserialized"), _jobId); + } } catch (BadRequirementException ex) {