Altinn / Altinn/app-lib-dotnet
Detect and forbid mutation in validation methods
- Dominant language
- C#
- Stars
- 8
- Forks
- 27
- Avg merge
- 1h 21m
- Merged PRs (30d)
- 7
Description
### Description
Service owners seem to think it is a good idea to mutate their data models in a `IFormDataValidator`. As our validators run in parallel, such mutations might cause race conditions. In addition it causes issues with our `PATCH` updates, when the mutations in the validator, does not follow the invariants defined in the `ObjectUtils` methods
https://github.com/Altinn/app-lib-dotnet/blob/1ac59d83211eae2d37ad8998cbc1c10c52c54632/src/Altinn.App.Core/Internal/Patch/PatchService.cs#L125-L149
### In scope
Pick a solution (or add another)
1. Find an (efficient - or dev only) way to detect and forbid mutations of the data object in validators.
2. Find an efficient way to always run validation on a copy to fix this particular issue.
3. Alternatively we can try to fix our code so that this (and other cases of validator mutations) work as expected by service owners
### Out of scope
_No response_
### Additional Information
_No response_
### Analysis
_No response_
### Conclusion
_No response_
Contributor guide
Research direction
Start with src/Altinn.App.Core/Internal/Patch/PatchService.cs around lines 125-149 and trace how IFormDataValidator instances receive and modify data models. The issue is complete when one agreed solution prevents validator mutations from causing parallel-validation races and PATCH invariant problems, with its behavior covered by the relevant tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100