From e835fb1867fa96121c3e3fa83c7f15a224db8dc5 Mon Sep 17 00:00:00 2001 From: Noah McGregor Harper <74685766+nharper285@users.noreply.github.com> Date: Fri, 7 Apr 2023 13:30:29 -0700 Subject: [PATCH] Adding handle for missing unique field key in `AdoFields` (#2986) * Adding handle for missing unique field key in . * Better approach. * Using TyGetValue. --- .../ApiService/onefuzzlib/notifications/Ado.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/ApiService/ApiService/onefuzzlib/notifications/Ado.cs b/src/ApiService/ApiService/onefuzzlib/notifications/Ado.cs index d79105e1d0..80ce2947a3 100644 --- a/src/ApiService/ApiService/onefuzzlib/notifications/Ado.cs +++ b/src/ApiService/ApiService/onefuzzlib/notifications/Ado.cs @@ -146,15 +146,19 @@ public async Async.Task Render(string template) { } } - public async IAsyncEnumerable ExistingWorkItems() { + public async IAsyncEnumerable ExistingWorkItems((string, string)[] notificationInfo) { var filters = new Dictionary(); foreach (var key in _config.UniqueFields) { var filter = string.Empty; if (string.Equals("System.TeamProject", key)) { filter = await Render(_config.Project); + } else if (_config.AdoFields.TryGetValue(key, out var field)) { + filter = await Render(field); } else { - filter = await Render(_config.AdoFields[key]); + _logTracer.WithTags(notificationInfo).Error($"Failed to check for existing work items using the UniqueField Key: {key}. Value is not present in config field AdoFields."); + continue; } + filters.Add(key.ToLowerInvariant(), filter); } @@ -327,7 +331,7 @@ private async Async.Task CreateNew() { } public async Async.Task Process((string, string)[] notificationInfo) { - var matchingWorkItems = await ExistingWorkItems().ToListAsync(); + var matchingWorkItems = await ExistingWorkItems(notificationInfo).ToListAsync(); var nonDuplicateWorkItems = matchingWorkItems .Where(wi => !IsADODuplicateWorkItem(wi))