-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
Hello! We have a record like this
public record TemplateRequirementsValidationRequestDto(
[property: DataMember(Name = "templateRequirements")]
string TemplateRequirements,
[property: DataMember(Name = "mailingKind")]
MailingKind MailingKind,
[property: DataMember(Name = "recipientsFileInternalId")]
int? RecipientsFileInternalId);
which we use in the endpoint like this
[HttpPost("do-smth")]
public async Task<JsonResult> DoSmth(
[FromBody] TemplateRequirementsValidationRequestDto request)
{
// ...
}
this code works stably and has been live for a whole year
Our application has several instances (2) with a balancer that proxies requests to one of these instances. And one day we saw this error:
InvalidOperationException: No property found that maps to constructor parameter 'RecipientsFileInternalId' for type 'Services.Core.TemplateRequirementsValidationRequestDto'. Validation requires that each bound parameter of a record type's primary constructor must have a property to read the value.
We did a little research and found out that the error occurred only on one instance, while the other instance worked without this error. Therefore, half of the requests completed successfully. After restarting the problematic instance, the errors disappeared
This error was introduced into the framework in this PR with the addition of support for records and appears in this place
The tests are not very informative in this particular place - so it was not possible to understand why this error occurred, perhaps there is a race somewhere or something else. Help me figure it out!
Expected Behavior
The error does not occur at random times
Steps To Reproduce
No steps
Exceptions (if any)
InvalidOperationException: No property found that maps to constructor parameter 'RecipientsFileInternalId' for type 'Services.Core.TemplateRequirementsValidationRequestDto'. Validation requires that each bound parameter of a record type's primary constructor must have a property to read the value.
.NET Version
8.0.x
Anything else?
No response