Serialization error after upgrade to v5.0.0
See original GitHub issueSo I have this code in my Startup.cs:
services.AddProblemDetails(setup =>
{
setup.IncludeExceptionDetails = (c, e) => environment.IsDevelopment(); // -> before updating to v5, I had _ =>environment.IsDevelopment(); here
setup.Map<DomainValidationException>(
(context, ex) => new ValidationProblemDetails(ex.Errors).Build(context));
});
Now my json looks like this, which blows up in deserialisation because of the duplicate “errors” field:
{
"errors": {
"exportPath": [
"..."
]
},
"type": "https://httpstatuses.com/400",
"title": "One or more validation errors occurred.",
"status": 400,
"detail": "Please refer to the errors property for additional details.",
"instance": "/api/externalApplications/4240656a-a669-4fba-842a-abbb00dca30f",
"errors": [
{
"message": "Domain validation failed. See Errors for details.",
[...]
Before the update (v4.5), the json was just
{
"errors": {
"exportPath": [
"..."
]
},
"type": "https://httpstatuses.com/400",
"title": "One or more validation errors occurred.",
"status": 400,
"detail": "Please refer to the errors property for additional details.",
"instance": "/api/externalApplications/7a52e19a-ce16-480c-9999-abbb00e0c8c7"
}
Fixed it by doing this in my startup, but I don’t know if this is what you intended:
setup.IncludeExceptionDetails = (c, e) =>
{
return e switch
{
DomainValidationException _ => false,
_ => environment.IsDevelopment()
};
};
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Upgrade to v5 fails using upgrade script · Issue #8553
The upgrade to v5 fails using the php upgrade.php script. ... Steps to reproduce the behavior: Attempt upgrade using php upgrade.php from v4.9.5 ......
Read more >My old program doesn't work after update 2022-KB5012159
When I update 2022-KB5012159.There has been an error.Not find assmbly ”System.Runtime.Serialization, Version=3.0.0.0,Culture=neutral.
Read more >Net 5 Api System.NotSupportedException: Serialization ...
I can see the controller action gets executed so deserialization works fine on the way in. It fails when writing response.
Read more >Errors in sync projects after upgrade from 8.2.1 to 9.1 - Forum
Hi,. We're performing a series of tests before upgrading our systems to 9.1. The process ends up flawlessly but the DPR migration processes ......
Read more >Patch Notes | Odin Inspector for Unity
Fixed a bug that would happen in newer versions of Unity, where clicking on an issue in the odin validator window would cause...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@khellang I was just hit by this too, 1 year later on 5.4 after upgrading from 4.5. I second the ☝️ suggestion of changing the default name to
exceptionDetails
.Out of the box, we run into problems with Refit no longer recognizing the validation error and throws
Refit.ApiException
instead ofRefit.ValidationApiException
, which loses theProblemDetails
it tries to deserialize for 400 Bad Request. Changing the property name fixed this.Update: Created PR #139 .
Just pushed v5.1.0 to NuGet. It has an additional
ExceptionDetailsPropertyName
option that should let you use a different name 😄