Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ODataQueryContext does not support unbound functions (OperationImportSegment) #1379

Open
Xriuk opened this issue Dec 19, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@Xriuk
Copy link

Xriuk commented Dec 19, 2024

Assemblies affected
ASP.NET Core OData 8.2.4

Describe the bug

.../odata/MyFunction()?$select=*

A query which selects all the properties with the wildcard selector on a collection of entities returned from an unbound function throws an exception:

   in Microsoft.OData.Edm.EdmUtil.CheckArgumentNull[T](T value, String parameterName) in Microsoft.OData.Edm\EdmUtil.cs: riga 363
   in Microsoft.OData.Edm.ExtensionMethods.<StructuralProperties>d__106.MoveNext() in Microsoft.OData.Edm\ExtensionMethods.cs: riga 1012
   in Microsoft.AspNetCore.OData.Query.Validator.SelectExpandQueryValidator.ValidateWildcardSelectItem(WildcardSelectItem wildCardSelectItem, SelectExpandValidatorContext validatorContext) in D:\a\1\s\src\Microsoft.AspNetCore.OData\Query\Validator\SelectExpandQueryValidator.cs: riga 338
   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 107
   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

It appears that ODataQueryContext.TargetStructuredType is null despite the returned type being a valid entity collection from an entity set.
The culprit should be here:

internal static (IEdmProperty, IEdmStructuredType, string) GetPropertyAndStructuredTypeFromPath(this ODataPath path)

because it appears that OperationImportSegment (which should be an unbound function/action) is not handled and is returning null.

In fact if I "patch" ODataPath by replacing OperationImportSegment with OperationSegment it works.

@Xriuk Xriuk added the bug Something isn't working label Dec 19, 2024
@Xriuk Xriuk changed the title ODataQueryOptions does not support unbound functions (OperationImportSegment) ODataQueryContext does not support unbound functions (OperationImportSegment) Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant