Skip to content

Commit 235babe

Browse files
committed
Fixed parse endpoint error handling of unknown events.
1 parent ca19c97 commit 235babe

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/SocketLabs.EventWebhooks.Extensions/Controllers/ParsedMessagesController.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,19 @@ public async Task<IActionResult> Post(WebhookEventBase webhookEvent, string id)
4141
{
4242
webhookEvent.WebhookEndpointName = id;
4343

44-
Task result = webhookEvent switch
44+
Task? result = webhookEvent switch
4545
{
4646
MessageParsedEvent eventItem => ProcessEvent(eventItem),
4747
ValidationEvent eventItem => ProcessEvent(eventItem),
48-
_ => throw new InvalidOperationException("Unable to convert event type.")
48+
_ => null
4949
};
5050

51+
if (result == null)
52+
{
53+
_logger.LogError("Unable to convert event type: {EventType} for MessageId: {MessageId}", webhookEvent.GetType().Name, webhookEvent.MessageId);
54+
return BadRequest($"Unknown event type: {webhookEvent.GetType().Name}");
55+
}
56+
5157
await result;
5258
}
5359
catch (Exception ex)

0 commit comments

Comments
 (0)