Applying ODataQueryOptions to IQueryable changes ODataQueryOptions state
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 505
- Forks
- 186
- PR merge metrics
- No merged PRs in 30d
Description
Applying ODataQueryOptions to IQueryable adds additional item to OrderByNodes collection if EnsureStableOrdering is true.
Subsequent calls to ODataQueryOptions.Validate will throw
NullReferenceException: Object reference not set to an instance of an object.
Microsoft.AspNetCore.OData.Query.Validator.OrderByModelLimitationsValidator.TryValidate(OrderByClause orderByClause, bool explicitPropertiesDefined)
Microsoft.AspNetCore.OData.Query.Validator.OrderByQueryValidator.Validate(OrderByQueryOption orderByOption, ODataValidationSettings validationSettings)
Microsoft.AspNetCore.OData.Query.OrderByQueryOption.Validate(ODataValidationSettings validationSettings)
Microsoft.AspNetCore.OData.Query.Validator.ODataQueryValidator.Validate(ODataQueryOptions options, ODataValidationSettings validationSettings)
Microsoft.AspNetCore.OData.Query.ODataQueryOptions.Validate(ODataValidationSettings validationSettings)
This is due to OrderByQueryValidator loops though order nodes and tries to pass corresponding order clause to OrderByModelLimitationsValidator.TryValidate method, and order clauses is null for newly added node.
Is it possible to either not change ODataQueryOptions state, or at least do it in a way that will allow reuse of the ODataQueryOptions (i.e. validation should not throw)?
OData v 8.0.1
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with ODataQueryOptions.ApplyTo and the OrderByQueryValidator path described in the stack trace, then inspect how EnsureStableOrdering adds an OrderByNode. Reproduce by applying the options to an IQueryable and calling Validate twice; done means repeated validation no longer throws and the options' reuse behavior is defined.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100