Repository navigation
Closed
Milestone
Description
I have an endpoint implemented as follows:
public sealed record RequestPasswordResetRequest(string EmailAddress);
public static class RequestPasswordResetEndpoint
{
[WolverinePut($"{Routes.Users}/request-password-reset")]
public static async Task RequestPasswordReset(
RequestPasswordResetRequest request,
IMessageBus bus,
IUserService userService)
{
var userId = await userService.GetUserIdByEmailAddress(request.EmailAddress);
if (!userId.HasValue)
return;
var cmd = new RequestPasswordReset(userId.Value, request.EmailAddress);
await bus.InvokeAsync(cmd);
}
}
public sealed record RequestPasswordReset(Guid UserId, string EmailAddress);
public static class RequestPasswordResetAggregateHandler
{
public static IEnumerable<object> Handle(RequestPasswordReset _, User user)
{
user.RequestPasswordReset();
return user.Changes;
}
}IUserService is registered as a scoped service. The concrete implementation takes a dependency on Marten's IQuerySession and nothing else.
When I hit the endpoint at runtime, the following error message is returned:
System.InvalidOperationException: Compilation failures!
CS1503: Argument 1: cannot convert from 'Wolverine.IMessageContext' to 'Wolverine.Runtime.MessageContext'
Code:
// <auto-generated/>
#pragma warning disable
using Microsoft.AspNetCore.Routing;
using System;
using System.Linq;
using Wolverine.Http;
using Wolverine.Marten.Publishing;
using Wolverine.Runtime;
namespace Internal.Generated.WolverineHandlers
{
// START: PUTapi_users_request_password_reset
public class PUTapi_users_request_password_reset : Wolverine.Http.HttpHandler
{
private readonly Wolverine.Http.WolverineHttpOptions _options;
private readonly Wolverine.Runtime.IWolverineRuntime _wolverineRuntime;
private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory;
public PUTapi_users_request_password_reset(Wolverine.Http.WolverineHttpOptions options, Wolverine.Runtime.IWolverineRuntime wolverineRuntime, Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory) : base(options)
{
_options = options;
_wolverineRuntime = wolverineRuntime;
_outboxedSessionFactory = outboxedSessionFactory;
}
public override async System.Threading.Tasks.Task Handle(Microsoft.AspNetCore.Http.HttpContext httpContext)
{
var messageContext = new Wolverine.Runtime.MessageContext(_wolverineRuntime);
await using var querySession = _outboxedSessionFactory.QuerySession(((Wolverine.IMessageContext)messageContext));
var userService = new Namespace.Here.Users.Services.UserService(querySession);
try
{
Wolverine.Http.Runtime.RequestIdMiddleware.Apply(httpContext, ((Wolverine.IMessageContext)messageContext));
var (request, jsonContinue) = await ReadJsonAsync<Namespace.Here.Users.Features.RequestPasswordResetRequest>(httpContext);
if (jsonContinue == Wolverine.HandlerContinuation.Stop) return;
await Namespace.Here.Users.Features.RequestPasswordResetEndpoint.RequestPasswordReset(request, ((Wolverine.IMessageBus)messageContext), userService).ConfigureAwait(false);
// Wolverine automatically sets the status code to 204 for empty responses
httpContext.Response.StatusCode = 204;
}
catch(System.Exception ex) when (Namespace.Here.HttpExceptionPolicy.CanHandleException(ex))
{
await Namespace.Here.HttpExceptionPolicy.HandleException(ex, httpContext);
return;
}
}
}
// END: PUTapi_users_request_password_reset
}
at JasperFx.RuntimeCompiler.AssemblyGenerator.Generate(String code)
at JasperFx.RuntimeCompiler.AssemblyGenerator.Compile(GeneratedAssembly generatedAssembly, IServiceVariableSource services)
at JasperFx.RuntimeCompiler.CodeFileExtensions.InitializeSynchronously(ICodeFile file, GenerationRules rules, ICodeFileCollection parent, IServiceProvider services)
at Wolverine.Http.HttpChain.<>c__DisplayClass66_0.<BuildEndpoint>b__0()
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy`1.CreateValue()
at Wolverine.Http.HttpChain.<>c__DisplayClass66_0.<BuildEndpoint>b__1(HttpContext c)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.Invoke(HttpContext httpContext)
--- End of stack trace from previous location ---
at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Serilog.AspNetCore.RequestLoggingMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
Metadata
Metadata
Assignees
Labels
No labels
Activity
lofbacke commentedon Jul 9, 2023
@jeremydmiller FYI, I am now receiving a similar exception when I try converting to aggregate handlers and HTTP endpoints in a single method and utilize the discard (
_) naming convention for the command object. In this case, I only need the command object for theUserId, not the business logic itself.It results in the following exception. If I change the name back to
cmd, it works.The offending code is located on lines 39 and 41 per the screenshot below.

lofbacke commentedon Jul 9, 2023
At the risk of becoming a squeaky wheel, I've now encountered a third scenario that produces this exception. Details below.
Endpoint:
TokenFactorytakes a dependency onIOptions<JwtIssuerOptions>and nothing else. The factory and the options are both registered with the IoC container.Exception message:
And the compilation error in the generated code happens in the constructor method where it passes the
optionsargument to thebaseconstructor. It doesn't differentiate between theWolverineHttpOptionsargument and theJwtIssuerOptionsargument.jeremydmiller commentedon Jul 10, 2023
@lofbacke Got the first one fixed locally. Starting the others now.
jeremydmiller commentedon Jul 10, 2023
Pfft, found some other issues while working through this.
lofbacke commentedon Jul 10, 2023
Thanks for the quick turnaround, @jeremydmiller!
Couple compilation issues with Marten IQuerySession, HTTP handlers wi…
Bump JasperFx + JasperFx.Events to 2.23.0 (MaxConcurrentRebuildsPerDa…