You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When I try using a built-in or custom function in an $orderby expression inside a $select I get the following exception:
NotImplementedException
in Microsoft.OData.UriParser.QueryNodeVisitor`1.Visit(ConvertNode nodeIn) in Microsoft.OData.UriParser\QueryNodeVisitor.cs: riga 54
in Microsoft.OData.UriParser.ConvertNode.Accept[T](QueryNodeVisitor`1 visitor) in Microsoft.OData.UriParser\ConvertNode.cs: riga 28
in Microsoft.AspNetCore.OData.Query.Validator.OrderByModelLimitationsValidator.Visit(SingleValueFunctionCallNode nodeIn) in D:\a\1\s\src\Microsoft.AspNetCore.OData\Query\Validator\OrderByModelLimitationsValidator.cs: riga 142
in Microsoft.OData.UriParser.SingleValueFunctionCallNode.Accept[T](QueryNodeVisitor`1 visitor) in Microsoft.OData.UriParser\SingleValueFunctionCallNode.cs: riga 55
in Microsoft.AspNetCore.OData.Query.Validator.OrderByModelLimitationsValidator.TryValidate(OrderByClause orderByClause, Boolean explicitPropertiesDefined) in D:\a\1\s\src\Microsoft.AspNetCore.OData\Query\Validator\OrderByModelLimitationsValidator.cs: riga 47
in Microsoft.AspNetCore.OData.Query.Validator.OrderByModelLimitationsValidator.TryValidate(IEdmProperty property, IEdmStructuredType structuredType, OrderByClause orderByClause, Boolean explicitPropertiesDefined) in D:\a\1\s\src\Microsoft.AspNetCore.OData\Query\Validator\OrderByModelLimitationsValidator.cs: riga 39
in Microsoft.AspNetCore.OData.Query.Validator.SelectExpandQueryValidator.ValidateNestedOrderby(OrderByClause orderByClause, SelectExpandValidatorContext validatorContext) in D:\a\1\s\src\Microsoft.AspNetCore.OData\Query\Validator\SelectExpandQueryValidator.cs: riga 405
in Microsoft.AspNetCore.OData.Query.Validator.SelectExpandQueryValidator.ValidatePathSelectItem(PathSelectItem pathSelectItem, SelectExpandValidatorContext validatorContext) in D:\a\1\s\src\Microsoft.AspNetCore.OData\Query\Validator\SelectExpandQueryValidator.cs: riga 303
in Microsoft.AspNetCore.OData.Query.Validator.SelectExpandQueryValidator.ValidateSelectExpand(SelectExpandClause selectExpandClause, SelectExpandValidatorContext validatorContext) in D:\a\1\s\src\Microsoft.AspNetCore.OData\Query\Validator\SelectExpandQueryValidator.cs: riga 102
in Microsoft.AspNetCore.OData.Query.Validator.SelectExpandQueryValidator.Validate(SelectExpandQueryOption selectExpandQueryOption, ODataValidationSettings validationSettings) in D:\a\1\s\src\Microsoft.AspNetCore.OData\Query\Validator\SelectExpandQueryValidator.cs: riga 54
in Microsoft.AspNetCore.OData.Query.SelectExpandQueryOption.Validate(ODataValidationSettings validationSettings) in D:\a\1\s\src\Microsoft.AspNetCore.OData\Query\Query\SelectExpandQueryOption.cs: riga 266
in Microsoft.AspNetCore.OData.Query.Validator.ODataQueryValidator.Validate(ODataQueryOptions options, ODataValidationSettings validationSettings) in D:\a\1\s\src\Microsoft.AspNetCore.OData\Query\Validator\ODataQueryValidator.cs: riga 106
in Microsoft.AspNetCore.OData.Query.ODataQueryOptions.Validate(ODataValidationSettings validationSettings) in D:\a\1\s\src\Microsoft.AspNetCore.OData\Query\ODataQueryOptions.cs: riga 652
...
Inside an $expand the exception is a bit different:
NotImplementedException
in Microsoft.OData.UriParser.QueryNodeVisitor`1.Visit(ConvertNode nodeIn) in Microsoft.OData.UriParser\QueryNodeVisitor.cs: riga 54
in Microsoft.OData.UriParser.ConvertNode.Accept[T](QueryNodeVisitor`1 visitor) in Microsoft.OData.UriParser\ConvertNode.cs: riga 28
in Microsoft.AspNetCore.OData.Query.Validator.OrderByModelLimitationsValidator.Visit(SingleValueFunctionCallNode nodeIn) in D:\a\1\s\src\Microsoft.AspNetCore.OData\Query\Validator\OrderByModelLimitationsValidator.cs: riga 142
in Microsoft.OData.UriParser.SingleValueFunctionCallNode.Accept[T](QueryNodeVisitor`1 visitor) in Microsoft.OData.UriParser\SingleValueFunctionCallNode.cs: riga 55
in Microsoft.AspNetCore.OData.Query.Validator.OrderByModelLimitationsValidator.TryValidate(OrderByClause orderByClause, Boolean explicitPropertiesDefined) in D:\a\1\s\src\Microsoft.AspNetCore.OData\Query\Validator\OrderByModelLimitationsValidator.cs: riga 47
in Microsoft.AspNetCore.OData.Query.Validator.OrderByModelLimitationsValidator.TryValidate(IEdmProperty property, IEdmStructuredType structuredType, OrderByClause orderByClause, Boolean explicitPropertiesDefined) in D:\a\1\s\src\Microsoft.AspNetCore.OData\Query\Validator\OrderByModelLimitationsValidator.cs: riga 39
in Microsoft.AspNetCore.OData.Query.Validator.SelectExpandQueryValidator.ValidateNestedOrderby(OrderByClause orderByClause, SelectExpandValidatorContext validatorContext) in D:\a\1\s\src\Microsoft.AspNetCore.OData\Query\Validator\SelectExpandQueryValidator.cs: riga 405
in Microsoft.AspNetCore.OData.Query.Validator.SelectExpandQueryValidator.ValidateExpandedNavigationSelectItem(ExpandedNavigationSelectItem expandItem, SelectExpandValidatorContext validatorContext) in D:\a\1\s\src\Microsoft.AspNetCore.OData\Query\Validator\SelectExpandQueryValidator.cs: riga 200
in Microsoft.AspNetCore.OData.Query.Validator.SelectExpandQueryValidator.ValidateSelectExpand(SelectExpandClause selectExpandClause, SelectExpandValidatorContext validatorContext) in D:\a\1\s\src\Microsoft.AspNetCore.OData\Query\Validator\SelectExpandQueryValidator.cs: riga 92
in Microsoft.AspNetCore.OData.Query.Validator.SelectExpandQueryValidator.Validate(SelectExpandQueryOption selectExpandQueryOption, ODataValidationSettings validationSettings) in D:\a\1\s\src\Microsoft.AspNetCore.OData\Query\Validator\SelectExpandQueryValidator.cs: riga 54
in Microsoft.AspNetCore.OData.Query.SelectExpandQueryOption.Validate(ODataValidationSettings validationSettings) in D:\a\1\s\src\Microsoft.AspNetCore.OData\Query\Query\SelectExpandQueryOption.cs: riga 266
in Microsoft.AspNetCore.OData.Query.Validator.ODataQueryValidator.Validate(ODataQueryOptions options, ODataValidationSettings validationSettings) in D:\a\1\s\src\Microsoft.AspNetCore.OData\Query\Validator\ODataQueryValidator.cs: riga 106
in Microsoft.AspNetCore.OData.Query.ODataQueryOptions.Validate(ODataValidationSettings validationSettings) in D:\a\1\s\src\Microsoft.AspNetCore.OData\Query\ODataQueryOptions.cs: riga 652
Reproduce steps
A query like $select=CollectionProperty($orderby=length(Code)) or $expand=CollectionNavigation($orderby=length(Code))
The text was updated successfully, but these errors were encountered:
The correct syntax for this request is $select=CollectionProperty($orderby=length(code=Code)) (note the parameter name inside of the custom function parameter list). Also note that we have strict parsing logic around spacing (so, do not include spaces around the =).
That said, we need to improve this error message to indicate what the issue actually is, especially since callers will likely want to surface this as a 4xx to let their client know to fix the syntax.
Assemblies affected
ASP.NET Core OData 8.2.4
Describe the bug
When I try using a built-in or custom function in an $orderby expression inside a $select I get the following exception:
Inside an $expand the exception is a bit different:
Reproduce steps
A query like
$select=CollectionProperty($orderby=length(Code))
or$expand=CollectionNavigation($orderby=length(Code))
The text was updated successfully, but these errors were encountered: