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

ArgumentNullException for: $filter=property in [''] #3092

Open
sriram-d opened this issue Oct 17, 2024 · 2 comments · May be fixed by #3122
Open

ArgumentNullException for: $filter=property in [''] #3092

sriram-d opened this issue Oct 17, 2024 · 2 comments · May be fixed by #3122
Assignees
Labels

Comments

@sriram-d
Copy link

Issue is similar to #2539, except for the use of square brackets rather than parenthesis. Also, issue happens for any regular property.

Assemblies affected

ODL version 8.0.1

Reproduce steps

// Setup basic model
var model = new EdmModel();
var user = model.AddEntityType("graph", "user", baseType: null, isAbstract: false, isOpen: true, hasStream: false);
var container = model.AddEntityContainer("graph", "service");
container.AddEntitySet("users", user);

// Setup URI parser
var parser = new ODataUriParser(model, new System.Uri("/users?$filter=openPropertyFoo in ('')", System.UriKind.Relative));
parser.ParsePath();

// This throws an ArgumentNullException:
var filter = parser.ParseFilter();

Expected result

Since syntax is not as expected, throw ODataException.

Actual result

Below exception is thrown.

System.ArgumentNullException: Value cannot be null or empty. (Parameter 'literalText')
   at Microsoft.OData.ExceptionUtils.CheckArgumentStringNotNullOrEmpty(String value, String parameterName)
   at Microsoft.OData.UriParser.ConstantNode..ctor(Object constantValue, String literalText, IEdmTypeReference typeReference)
   at Microsoft.OData.UriParser.CollectionConstantNode..ctor(IEnumerable`1 objectCollection, String literalText, IEdmCollectionTypeReference collectionType)
   at Microsoft.OData.UriParser.LiteralBinder.BindInLiteral(LiteralToken literalToken)
   at Microsoft.OData.UriParser.MetadataBinder.<BindIn>b__22_0(QueryToken queryToken)
   at Microsoft.OData.UriParser.InBinder.GetCollectionOperandFromToken(QueryToken queryToken, IEdmTypeReference expectedType, IEdmModel model)
   at Microsoft.OData.UriParser.InBinder.BindInOperator(InToken inToken, BindingState state)
   at Microsoft.OData.UriParser.MetadataBinder.BindIn(InToken inToken)
   at Microsoft.OData.UriParser.MetadataBinder.Bind(QueryToken token)
   at Microsoft.OData.UriParser.FilterBinder.BindFilter(QueryToken filter)
   at Microsoft.OData.UriParser.ODataQueryOptionParser.ParseFilterImplementation(String filter, ODataUriParserConfiguration configuration, ODataPathInfo odataPathInfo)
   at Microsoft.OData.UriParser.ODataQueryOptionParser.ParseFilter()
   at Microsoft.OData.UriParser.ODataUriParser.ParseFilter()
   at MyPlayGround.Program.Main(String[] args) in C:\Users\sriramd\source\repos\MyPlayGround\Program.cs:line 25
@syprieur
Copy link
Contributor

Clarification: repro URI from code snippet above is with square brackets:
/users?$filter=openPropertyFoo in [""] or /users?$filter=openPropertyFoo in ['']

It occurs for both open and schema-defined properties (even a simple primary key property of type string).

@WanjohiSammy
Copy link
Contributor

@sriram-d Thanks for pointing this out.

What if you try with some strings in the [], for example, ['one', 'two']

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants