You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
it then crashes on InvokeAsync method because the properties are expected there.
Error message:
System.ArgumentNullException: Value cannot be null. (Parameter 'value')
at Newtonsoft.Json.Linq.JToken.EnsureValue(JToken value)
at Newtonsoft.Json.Linq.JToken.op_Explicit(JToken value)
at EventManager.Middleware.EventManagerMiddleware.InvokeAsync(HttpContext httpContext)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
HEADERS
=======
Accept: */*
Accept-Encoding: gzip, deflate, br
Cache-Control: no-cache
Connection: keep-alive
Content-Length: 868
Content-Type: application/json
Host: localhost:40861
User-Agent: PostmanRuntime/7.26.8
Postman-Token: a109ae8c-af76-4e17-9e83-c988a6dc32b3
Another issue:
Also, malformed json payload (missing the last curly brace) throws the following error:
Newtonsoft.Json.JsonReaderException: Unexpected end of content while loading JObject. Path 'key', line 42, position 2.
at Newtonsoft.Json.Linq.JContainer.ReadTokenFrom(JsonReader reader, JsonLoadSettings options)
at Newtonsoft.Json.Linq.JObject.Load(JsonReader reader, JsonLoadSettings settings)
at Newtonsoft.Json.Linq.JObject.Parse(String json, JsonLoadSettings settings)
at Newtonsoft.Json.Linq.JObject.Parse(String json)
at EventManager.Middleware.EventManagerMiddleware.InvokeAsync(HttpContext httpContext)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
HEADERS
=======
Accept: */*
Accept-Encoding: gzip, deflate, br
Cache-Control: no-cache
Connection: keep-alive
Content-Length: 867
Content-Type: application/json
Host: localhost:40861
User-Agent: PostmanRuntime/7.26.8
Postman-Token: 7a9b0216-4e88-46d3-9d43-378b5b3df382
Possible Solutions:
Dispatch/ throw an exception (BadRequest or similar) that can be catched on upper calls, one for the properties, and another one for the malformed json
The text was updated successfully, but these errors were encountered:
Thanks for creating this issue! I would suggest doing as you say but creating a custom exception (eg, MalformedEventDispatch), so that it is clearer what is happening.
Another thing we can do is have the EventManagerMiddleware return a BadRequest status code whenever someone sends a request to the event reception endpoint using a malformed event.
Problem description:
EventManager endpoint expects the following structure for a payload:
But if the payload differs like this one:
it then crashes on
InvokeAsync
method because the properties are expected there.Error message:
Another issue:
Also, malformed json payload (missing the last curly brace) throws the following error:
Possible Solutions:
Dispatch/ throw an exception (BadRequest or similar) that can be catched on upper calls, one for the properties, and another one for the malformed json
The text was updated successfully, but these errors were encountered: