Unable to send emails using custom pipeline in RC3.0.0-rc0050
Hi Matt,
We are using a custom pipeline task to send emails via the SendGrid API, which worked fine in the previous version but is throwing an error in the RC. I am registering the pipeline task in startup like so:
I've pasted the error below, it looks like the default email send task is being hit even though I've replaced it.
Any ides what I'm doing wrong?
at Vendr.Infrastructure.Resiliency.PollyExecutionStrategyBase.Execute[TResult](Func`1 operation, Func`1 verifySucceeded)
at Vendr.Core.Services.EmailTemplateService.SendEmail[TModel](EmailTemplateReadOnly emailTemplate, TModel model, String toEmailAddress, String languageIsoCode)
at Vendr.Umbraco.Web.Controllers.VendrEmailController.SendEmail[TModel](SendEmailDto cfg, OrderReadOnly order, TModel model)
at Vendr.Umbraco.Web.Controllers.VendrEmailController.SendOrderEmail(SendOrderEmailDto dto)
at lambda_method1482(Closure , Object , Object[] )
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
Hmm, nothing in the stack trace suggests it's running the default send task as it's the EmailTemplateService that triggers the pipeline. Unfortunately that stack trace isn't giving much away as to what is actually erroring 🤔
I'm guessing this doesn't actually hit any breakpoints in your SendEmailWithSendGridTask?
PS is there an exception message that goes along with that stack trace? I'm not exactly sure what it's erroring over.
Just to follow up on this, this morning I thought I'd just test swapping out tasks and so implemented exactly what you've presented here, inside a vendr builder removing a task and replacing a task with an alternative implementation and for me it worked as expected.
The removed / replaced tasks don't get hit via a breakpoint, but the replacement task does. If I cause my replacement task to throw an exception, it does throw something similar to what you were seeing (though not a 100% match) so it could still be an issue within your replacement task.
So the error is actually caused when the Template View field on an Email Template doesn't resolve to a physical razor template. For example a typo will cause this error.
For most use cases this is probably desirable, although maybe a friendlier error could be thrown, but in my case I actually use that field to define the TemplateID for the Send Grid email template.
In the previous version this approach works without issue. Is there anything in V3 that would cause this issue and is there anyway to circumvent it?
Also as a side note I noticed that errors thrown during email pipelines are not logged to the Umbraco log by default, is that intentional?
Hmmm, the only place that uses that property though is the RenderEmailTemplateTask so I wouldn't expect the pipeline to throw an exception if the task had been removed 🤔
You are calling AddVendr after AddComposers, but Vendr has a default composer to add vendr if it hasn't already been added and so by the time you call AddVendr vendr has already been added and so escapes without modifying the config, and so non of your changes are being applied.
I actually put the AddVendr call after AddComposers conciously as my pipeline depended on a few services I thought needed to be register first. But a few simple changes and it's back to working as expected again. 👍🏻
Unable to send emails using custom pipeline in RC3.0.0-rc0050
Hi Matt,
We are using a custom pipeline task to send emails via the SendGrid API, which worked fine in the previous version but is throwing an error in the RC. I am registering the pipeline task in startup like so:
I've pasted the error below, it looks like the default email send task is being hit even though I've replaced it.
Any ides what I'm doing wrong?
Hmm, nothing in the stack trace suggests it's running the default send task as it's the
EmailTemplateService
that triggers the pipeline. Unfortunately that stack trace isn't giving much away as to what is actually erroring 🤔I'm guessing this doesn't actually hit any breakpoints in your
SendEmailWithSendGridTask
?PS is there an exception message that goes along with that stack trace? I'm not exactly sure what it's erroring over.
Just to follow up on this, this morning I thought I'd just test swapping out tasks and so implemented exactly what you've presented here, inside a vendr builder removing a task and replacing a task with an alternative implementation and for me it worked as expected.
The removed / replaced tasks don't get hit via a breakpoint, but the replacement task does. If I cause my replacement task to throw an exception, it does throw something similar to what you were seeing (though not a 100% match) so it could still be an issue within your replacement task.
Hi Matt,
Thanks for investigating, ok I'll do some more digging it could be that something is throwing an obscure error somewhere that's not being caught.
Hi Matt,
Ok I've got a bit more info for you.
So the error is actually caused when the Template View field on an Email Template doesn't resolve to a physical razor template. For example a typo will cause this error.
For most use cases this is probably desirable, although maybe a friendlier error could be thrown, but in my case I actually use that field to define the TemplateID for the Send Grid email template.
In the previous version this approach works without issue. Is there anything in V3 that would cause this issue and is there anyway to circumvent it?
Also as a side note I noticed that errors thrown during email pipelines are not logged to the Umbraco log by default, is that intentional?
Thanks again for your time. 🙏🏻
Hmmm, the only place that uses that property though is the
RenderEmailTemplateTask
so I wouldn't expect the pipeline to throw an exception if the task had been removed 🤔Actually, I think I may know what it is.
You are calling
AddVendr
afterAddComposers
, but Vendr has a default composer to add vendr if it hasn't already been added and so by the time you callAddVendr
vendr has already been added and so escapes without modifying the config, and so non of your changes are being applied.Check the docs here and you'll see it should be called before
AddComposers
https://vendr.net/docs/core/3.0.0/key-concepts/vendr-builder/Hi Matt,
You're absolutely right, that was the issue.
I actually put the
AddVendr
call afterAddComposers
conciously as my pipeline depended on a few services I thought needed to be register first. But a few simple changes and it's back to working as expected again. 👍🏻Thanks for your help!
Perfect!
Glad it's up and working.
I was holding off releasing v3 incase this was a bug so I can get that out the door now too 🥳
is working on a reply...