-
Type: Bug
-
Resolution: Unresolved
-
Priority: Minor - P4
-
None
-
Affects Version/s: 2.10.0
-
Component/s: Builders
-
None
-
Environment:asp net core 3.1
-
Minor Change
Our team has been working on building a collection of filter definitions to query against and we noticed in our tests that when adding a null value to the collection, we end up getting a NullReferenceException.
It appears that, while the collection is being Ensured that it's not null, the entities get no validation pass and are assumed to be correct.
public AndFilterDefinition(IEnumerable<FilterDefinition<TDocument>> filters)
{{ {}}
{{ _filters = Ensure.IsNotNull(filters, nameof(filters)).ToList();}}
{{ }}}
If we look at the Render a little further down in the FilterDefinitionBuilder.cs, we see _filters iterated over:
foreach (var filter in _filters)
{{ {}}
{{ var renderedFilter = filter.Render(documentSerializer, serializerRegistry);}}
If _filters contains a null, this will trigger a NullReferenceException.