-
Notifications
You must be signed in to change notification settings - Fork 358
Description
Describe the bug
Let's say you have a schema with a top-level unbound function import that does not have an entity set path, the function is composable and returns a collection of entities (but not bound to an entity set).
If you make a request to the function, then query the results using a nested $filter inside an $expand query option like so:
GET /GetActiveCustomers()?$expand=Orders($filter=TotalPrice gt 1000)
You'll get an exception like the following
System.ArgumentNullException: Value cannot be null. (Parameter 'initialState')
ExceptionUtils.CheckArgumentNotNull[T](T value, String parameterName)
MetadataBinder.ctor(BindingState initialState)
SelectExpandBinder.BuildNewMetadataBinder(ODataUriParserConfiguration config, IEdmNavigationSource resourcePathNavigationSource, IEdmNavigationSource targetNavigationSource, IEdmTypeReference elementType, HashSet`1 generatedProperties, Boolean collapsed)
SelectExpandBinder.BindFilter(QueryToken filterToken, IEdmNavigationSource resourcePathNavigationSource, IEdmNavigationSource targetNavigationSource, IEdmTypeReference elementType, HashSet`1 generatedProperties, Boolean collapsed)
SelectExpandBinder.GenerateExpandItem(ExpandTermToken tokenIn)
SelectEnumerableIterator`2.MoveNext()
WhereEnumerableIterator`1.MoveNext()
List`1.AddRange(IEnumerable`1 collection)
SelectExpandBinder.Bind(ExpandToken expandToken, SelectToken selectToken)
SelectExpandSemanticBinder.Bind(ODataPathInfo odataPathInfo, ExpandToken expandToken, SelectToken selectToken, ODataUriParserConfiguration configuration, BindingState state)
ODataQueryOptionParser.ParseSelectAndExpandImplementation(String select, String expand, ODataUriParserConfiguration configuration, ODataPathInfo odataPathInfo)
ODataQueryOptionParser.ParseSelectAndExpand()
ODataUriParser.ParseSelectAndExpand()
Here's the culprit
Seems like it's caused by the resourcePathNavigationSource being null, causing CreateBindingState returning null, which causes the MetadataBinder constructor to throw the argument null exception.
PS: This also seems to affect nested $orderby.
Assemblies affected
Which assemblies and versions are known to be affected e.g. Microsoft.OData.Core 8.x
Steps to Reproduce
The simplest set of steps to reproduce the issue. If possible, reference a commit that demonstrates the issue.
Expected behaviour
What would happen if there wasn't a bug.
Actual behaviour
What is actually happening.
Additional details
Optional, details of the root cause if known. Delete this section if you have no additional details to add.