d-velop / dvelop-app-template-cs

This template contains everything you need to write an app for d.velop cloud in C#
Apache License 2.0
16 stars 7 forks source link

GET with invalid Accept-Header returns status code 500 #43

Closed tobiwsta closed 4 years ago

tobiwsta commented 5 years ago

A HTTP-GET with an invalid Accept header value, e.g. "acme" returns an InternalServerError.

START RequestId: b6ad4acd-fc99-4dbd-b1d0-71682cfbb8a2 Version: 92
[Debug] Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction: Incoming GET requests to /<Root>
[Debug] Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction: ASP.NET Core Request PathBase: , Path: /<Root>
[Information] Microsoft.AspNetCore.Hosting.Internal.WebHost: Request starting GET <Root-URL>
[Error] Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware: An unhandled exception has occurred while executing the request.
[Error] Dvelop.Remote.Startup: An unhandled error occured: System.ArgumentNullException: Value cannot be null. Parameter name: source at System.Linq.Enumerable.Select[TSource,TResult](IEnumerable`1 source, Func`2 selector) at Dvelop.Remote.Constraints.ProducesConstraintAttribute.<>c__DisplayClass5_0.<IsValidForRequest>b__2(String producesType) in /buildinternal/Remote/Constraints/ProducesCon
[Information] Microsoft.AspNetCore.Hosting.Internal.WebHost: Request finished in 1.0458ms 500 application/json
[Debug] Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction: Response Base 64 Encoded: False
END RequestId: b6ad4acd-fc99-4dbd-b1d0-71682cfbb8a2

The linq statement in ProducesConstraintAttribute.IsValidForRequest has an bug. For invalid MimeTypes the list requestHeaders.Accept is null.