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

Include AssignedTo when failing to create a work item due to an authentication exception #2770

Merged
2 changes: 1 addition & 1 deletion src/ApiService/ApiService/Functions/Notifications.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ private async Async.Task<HttpResponseData> Get(HttpRequestData req) {
return await _context.RequestHandling.NotOk(req, request.ErrorV, "notification search");
}

var entries = request.OkV switch { { Container: null } => _context.NotificationOperations.SearchAll(), { Container: var c } => _context.NotificationOperations.SearchByRowKeys(c.Select(x => x.String))
var entries = request.OkV switch { { Container: null, NotificationId: null } => _context.NotificationOperations.SearchAll(), { Container: var c, NotificationId: null } => _context.NotificationOperations.SearchByRowKeys(c.Select(x => x.String)), { Container: var _, NotificationId: var n } => new[] { await _context.NotificationOperations.GetNotification(n.Value) }.ToAsyncEnumerable(),
};

var response = req.CreateResponse(HttpStatusCode.OK);
Expand Down
3 changes: 2 additions & 1 deletion src/ApiService/ApiService/OneFuzzTypes/Requests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ public record NotificationCreate(
) : BaseRequest;

public record NotificationSearch(
List<Container>? Container
List<Container>? Container,
Guid? NotificationId
) : BaseRequest;

public record NotificationGet(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public interface INotificationOperations : IOrm<Notification> {
IAsyncEnumerable<Notification> GetNotifications(Container container);
IAsyncEnumerable<(Task, IEnumerable<Container>)> GetQueueTasks();
Async.Task<OneFuzzResult<Notification>> Create(Container container, NotificationTemplate config, bool replaceExisting);
Async.Task<Notification> GetNotification(Guid notifificationId);
}

public class NotificationOperations : Orm<Notification>, INotificationOperations {
Expand Down Expand Up @@ -142,4 +143,8 @@ private async Async.Task<NotificationTemplate> HideSecrets(NotificationTemplate
_logTracer.Error($"unable to find crash_report or no repro entry for report: {JsonSerializer.Serialize(report)}");
return null;
}

public async Async.Task<Notification> GetNotification(Guid notifificationId) {
tevoinea marked this conversation as resolved.
Show resolved Hide resolved
return await SearchByPartitionKeys(new[] { notifificationId.ToString() }).SingleAsync();
}
}
5 changes: 5 additions & 0 deletions src/ApiService/ApiService/onefuzzlib/notifications/Ado.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ public async Async.Task NotifyAdo(AdoTemplate config, Container container, strin
await ado.Process(notificationInfo);
} catch (Exception e)
when (e is VssAuthenticationException || e is VssServiceException) {
var _ = config.AdoFields.TryGetValue("System.AssignedTo", out var assignedTo);
if (e is VssAuthenticationException && !string.IsNullOrEmpty(assignedTo)) {
notificationInfo = notificationInfo.AddRange(new (string, string)[] { ("assigned_to", assignedTo) });
}

if (!isLastRetryAttempt && IsTransient(e)) {
_logTracer.WithTags(notificationInfo).Error($"transient ADO notification failure {report.JobId:Tag:JobId} {report.TaskId:Tag:TaskId} {container:Tag:Container} {filename:Tag:Filename}");
throw;
Expand Down