Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Commit

Permalink
Adding handle for missing unique field key in AdoFields (#2986)
Browse files Browse the repository at this point in the history
* Adding handle for missing unique field key in .

* Better approach.

* Using TyGetValue.
  • Loading branch information
nharper285 authored Apr 7, 2023
1 parent 1ae0639 commit e835fb1
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/ApiService/ApiService/onefuzzlib/notifications/Ado.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,19 @@ public async Async.Task<string> Render(string template) {
}
}

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);
}

Expand Down Expand Up @@ -327,7 +331,7 @@ private async Async.Task<WorkItem> 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))
Expand Down

0 comments on commit e835fb1

Please sign in to comment.