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

Commit e5d1e2c

Browse files
authored
Merge branch 'main' into user/noharper/config-endpoint-update-2
2 parents ab844c8 + 3d2fb65 commit e5d1e2c

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

src/ApiService/ApiService/onefuzzlib/WebhookOperations.cs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Text.Json;
55
using System.Threading.Tasks;
66
using ApiService.OneFuzzLib.Orm;
7+
using Azure;
78
using Microsoft.OneFuzz.Service.OneFuzzLib.Orm;
89

910
namespace Microsoft.OneFuzz.Service;
@@ -49,18 +50,31 @@ async private Async.Task AddEvent(Webhook webhook, EventMessage eventMessage) {
4950
var r = await _context.WebhookMessageLogOperations.Replace(message);
5051
if (!r.IsOk) {
5152
if (r.ErrorV.Reason.Contains("The entity is larger than the maximum allowed size") && eventMessage.Event is ITruncatable<BaseEvent> truncatableEvent) {
52-
_logTracer.WithTags(tags).Warning($"The WebhookMessageLog was too long. Truncating event data and trying again.");
53-
var truncatedEventMessage = message with {
53+
_logTracer.WithTags(tags).Warning($"The WebhookMessageLog was too long for Azure Table. Truncating event data and trying again.");
54+
message = message with {
5455
Event = truncatableEvent.Truncate(1000)
5556
};
56-
r = await _context.WebhookMessageLogOperations.Replace(truncatedEventMessage);
57+
r = await _context.WebhookMessageLogOperations.Replace(message);
5758
}
5859
if (!r.IsOk) {
5960
_logTracer.WithHttpStatus(r.ErrorV).WithTags(tags).Error($"Failed to replace webhook message log {webhook.WebhookId:Tag:WebhookId} - {eventMessage.EventId:Tag:EventId}");
6061
}
6162
}
6263

63-
await _context.WebhookMessageLogOperations.QueueWebhook(message);
64+
try {
65+
await _context.WebhookMessageLogOperations.QueueWebhook(message);
66+
} catch (RequestFailedException ex) {
67+
if (ex.Message.Contains("The request body is too large") && eventMessage.Event is ITruncatable<BaseEvent> truncatableEvent) {
68+
_logTracer.WithTags(tags).Warning($"The WebhookMessageLog was too long for Azure Queue. Truncating event data and trying again.");
69+
message = message with {
70+
Event = truncatableEvent.Truncate(1000)
71+
};
72+
await _context.WebhookMessageLogOperations.QueueWebhook(message);
73+
} else {
74+
// Not handled
75+
throw ex;
76+
}
77+
}
6478
}
6579

6680
public async Async.Task<bool> Send(WebhookMessageLog messageLog) {

0 commit comments

Comments
 (0)