An unhandled exception has occurred while executing the request.
LipatovAlexander opened this issue · comments
An exception occurs if you send an empty POST request to /slack/action.
fail: SlackNet[0]
Error handling request
RequestId: 0HMOADENJOKJS:00000002
Source: SlackNet.AspNetCore.SlackRequestHandler
Exception: System.InvalidOperationException: Incorrect Content-Type:
at Microsoft.AspNetCore.Http.Features.FormFeature.InnerReadFormAsync(CancellationToken cancellationToken)
at SlackNet.AspNetCore.SlackRequestHandler.DeserializePayload[T](HttpRequest request)
at SlackNet.AspNetCore.SlackRequestHandler.<>c__DisplayClass9_0.<<HandleActionRequest>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at SlackNet.AspNetCore.SlackRequestHandler.InRequestContext(HttpRequest request, Func`2 handleRequest)
fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
An unhandled exception has occurred while executing the request.
System.InvalidOperationException: Incorrect Content-Type:
at Microsoft.AspNetCore.Http.Features.FormFeature.InnerReadFormAsync(CancellationToken cancellationToken)
at SlackNet.AspNetCore.SlackRequestHandler.DeserializePayload[T](HttpRequest request)
at SlackNet.AspNetCore.SlackRequestHandler.<>c__DisplayClass9_0.<<HandleActionRequest>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at SlackNet.AspNetCore.SlackRequestHandler.InRequestContext(HttpRequest request, Func`2 handleRequest)
at SlackNet.AspNetCore.SlackRequestMiddleware.Invoke(HttpContext context)
at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
at Services.Configurations.ExceptionHandlers.ValidationExceptionHandler.InvokeAsync(HttpContext context, ProblemDetailsFactory problemDetailsFactory) in C:\Users\pc\source\repos\tilly\src\Services\Configurations\ExceptionHa
ndlers\ValidationExceptionHandler.cs:line 23
at Services.Configurations.ExceptionHandlers.HttpExceptionHandler.InvokeAsync(HttpContext context) in C:\Users\pc\source\repos\tilly\src\Services\Configurations\ExceptionHandlers\HttpExceptionHandler.cs:line 18
at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
It looks like it crashes when trying to deserialize payload:
https://github.com/soxtoby/SlackNet/blob/master/SlackNet.AspNetCore/SlackRequestHandler.cs#L393-L400
Thanks for raising this, @LipatovAlexander. I'll push up a new version that handles this scenario soon.
I'm curious what the effect of this unhandled exception is though; is it just being logged as an unhandled exception, or is it something worse, such as bringing down the application?
I'm curious what the effect of this unhandled exception is though; is it just being logged as an unhandled exception, or is it something worse, such as bringing down the application?
Just logs and returns 500 status
Ok, cool - I'm not too concerned then. The content type check I added in v0.10.21 should hopefully suffice.