Adding handle for missing unique field key in AdoFields (#2986)

* Adding handle for missing unique field key in .

* Better approach.

* Using TyGetValue.
This commit is contained in:
Noah McGregor Harper 2023-04-07 13:30:29 -07:00 committed by GitHub
parent 1ae063969b
commit e835fb1867
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -146,15 +146,19 @@ public class Ado : NotificationsBase, IAdo {
}
}
public async IAsyncEnumerable<WorkItem> ExistingWorkItems() {
public async IAsyncEnumerable<WorkItem> ExistingWorkItems((string, string)[] notificationInfo) {
var filters = new Dictionary<string, string>();
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 @@ public class Ado : NotificationsBase, IAdo {
}
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))