diff --git a/src/ReC.Application/RecActions/Commands/InvokeRecActionCommand.cs b/src/ReC.Application/RecActions/Commands/InvokeRecActionCommand.cs index e8ae005..f7d95da 100644 --- a/src/ReC.Application/RecActions/Commands/InvokeRecActionCommand.cs +++ b/src/ReC.Application/RecActions/Commands/InvokeRecActionCommand.cs @@ -1,4 +1,5 @@ using MediatR; +using Microsoft.Extensions.Logging; using ReC.Application.RecActions.Queries; namespace ReC.Application.RecActions.Commands; @@ -13,7 +14,7 @@ public static class InvokeRecActionCommandExtensions => sender.Send(new InvokeRecActionCommand { ProfileId = profileId }); } -public class InvokeRecActionCommandHandler(ISender sender, IHttpClientFactory clientFactory) : IRequestHandler +public class InvokeRecActionCommandHandler(ISender sender, IHttpClientFactory clientFactory, ILogger? logger = null) : IRequestHandler { public async Task Handle(InvokeRecActionCommand request, CancellationToken cancel) { @@ -28,6 +29,16 @@ public class InvokeRecActionCommandHandler(ISender sender, IHttpClientFactory cl await semaphore.WaitAsync(cancel); try { + if (action.RestType is null) + { + logger?.LogWarning( + "Rec action could not be invoked because the RestType value is null. ProfileId: {ProfileId}, ActionId: {ActionId}", + action.ProfileId, + action.ActionId + ); + return; + } + var method = new HttpMethod(action.RestType.ToUpper()); var msg = new HttpRequestMessage(method, action.EndpointUri);