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

Unhandled exception for parameter alias as 'in' filter collection #3138

Open
syprieur opened this issue Dec 3, 2024 · 0 comments
Open

Unhandled exception for parameter alias as 'in' filter collection #3138

syprieur opened this issue Dec 3, 2024 · 0 comments
Assignees
Labels

Comments

@syprieur
Copy link
Contributor

syprieur commented Dec 3, 2024

When a parameter alias is used as the collection of an in $filter, OData throws an unhandled exception.

Assemblies affected

Possibly all. Observed in ODL 8.1.0 and 8.2.2.

Reproduce steps

var model = new EdmModel();

var person = new EdmEntityType("my.namespace", "person");
person.AddKeys(person.AddStructuralProperty("id", EdmPrimitiveTypeKind.String));
model.AddElement(person);

var container = new EdmEntityContainer("my.namespace", "container");
model.AddElement(container);
container.AddEntitySet("people", person);

var parser = new ODataUriParser(model, new Uri("""/people?$filter=id in @ids&@ids=["foo"]""", UriKind.Relative))
{
    Resolver = new UnqualifiedODataUriResolver() { EnableCaseInsensitive = true },
    UrlKeyDelimiter = ODataUrlKeyDelimiter.Slash,
};
parser.Settings.MaximumExpansionDepth = 2;
parser.ParsePath();
var filter = parser.ParseFilter();

Expected result

An ODataException if this is not intended to be supported, or the same behavior as when parameter aliases are not used.

Actual result

Unhandled exception thrown by ODL:

System.ArgumentNullException: Value cannot be null. (Parameter 'type')

Stack Trace: 
  EdmUtil.CheckArgumentNull[T](T value, String parameterName)
  EdmTypeSemantics.IsStructured(IEdmTypeReference type)
  ParameterAliasBinder.ParseComplexOrCollectionAlias(QueryToken queryToken, IEdmTypeReference parameterType, IEdmModel model)
  ParameterAliasBinder.ParseAndBindParameterAliasValueExpression(BindingState bindingState, String aliasValueExpression, IEdmTypeReference parameterType)
  ParameterAliasBinder.BindParameterAlias(BindingState bindingState, FunctionParameterAliasToken aliasToken)
  MetadataBinder.BindParameterAlias(FunctionParameterAliasToken functionParameterAliasToken)
  MetadataBinder.Bind(QueryToken token)
  MetadataBinder.<BindIn>b__22_0(QueryToken queryToken)
  InBinder.GetCollectionOperandFromToken(QueryToken queryToken, IEdmTypeReference expectedType, IEdmModel model)
  InBinder.BindInOperator(InToken inToken, BindingState state)
  MetadataBinder.BindIn(InToken inToken)
  MetadataBinder.Bind(QueryToken token)
  FilterBinder.BindFilter(QueryToken filter)
  ODataQueryOptionParser.ParseFilterImplementation(String filter, ODataUriParserConfiguration configuration, ODataPathInfo odataPathInfo)
  ODataQueryOptionParser.ParseFilter()
  ODataUriParser.ParseFilter()
@marabooy marabooy self-assigned this Dec 3, 2024
@marabooy marabooy added the P2 label Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants