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 · 1 comment
Open

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

sriram-d opened this issue Oct 17, 2024 · 1 comment

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).

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

No branches or pull requests

2 participants