You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
http://host/service/TestEntity?$filter=NullablePropertyInt in (1,2,null)
Expected result
The list of all the TestEntity with 1, 2 or NULL as the value of the property NullablePropertyInt.
Actual result
An NullReferenceException is thrown:
System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.OData.UriParser.CollectionConstantNode..ctor(IEnumerable`1 objectCollection, String literalText, IEdmCollectionTypeReference collectionType)
at Microsoft.OData.UriParser.LiteralBinder.BindLiteral(LiteralToken literalToken)
at Microsoft.OData.UriParser.MetadataBinder.Bind(QueryToken token)
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.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()
Additional detail
if we try the same query on the non nullable property, we are receiving an ODataException explaining the NULL value is not allowed, which is correct.
http://host/service/TestEntity?$filter=PropertyInt in (1,2,null)
Microsoft.OData.ODataException: A null value was found with the expected type 'Edm.Int32[Nullable=False]'. The expected type 'Edm.Int32[Nullable=False]' does not allow null values.
at Microsoft.OData.ReaderValidationUtils.ThrowNullValueForNonNullableTypeException(IEdmTypeReference expectedValueTypeReference, String propertyName)
at Microsoft.OData.ReaderValidationUtils.ValidateNullValueAllowed(IEdmTypeReference expectedValueTypeReference, Boolean validateNullValue, String propertyName, Nullable`1 isDynamicProperty)
at Microsoft.OData.ReaderValidator.ValidateNullValue(IEdmTypeReference expectedTypeReference, Boolean validateNullValue, String propertyName, Nullable`1 isDynamicProperty)
at Microsoft.OData.Json.ODataJsonReaderCoreUtils.TryReadNullValue(IJsonReader jsonReader, ODataInputContext inputContext, IEdmTypeReference expectedTypeReference, Boolean validateNullValue, String propertyName, Nullable`1 isDynamicProperty)
at Microsoft.OData.JsonLight.ODataJsonLightPropertyAndValueDeserializer.ReadNonEntityValueImplementation(String payloadTypeName, IEdmTypeReference expectedTypeReference, PropertyAndAnnotationCollector propertyAndAnnotationCollector, CollectionWithoutExpectedTypeValidator collectionValidator, Boolean validateNullValue, Boolean isTopLevelPropertyValue, Boolean insideResourceValue, String propertyName, Nullable`1 isDynamicProperty)
at Microsoft.OData.JsonLight.ODataJsonLightPropertyAndValueDeserializer.ReadCollectionValue(IEdmCollectionTypeReference collectionValueTypeReference, String payloadTypeName, ODataTypeAnnotation typeAnnotation)
at Microsoft.OData.JsonLight.ODataJsonLightPropertyAndValueDeserializer.ReadNonEntityValueImplementation(String payloadTypeName, IEdmTypeReference expectedTypeReference, PropertyAndAnnotationCollector propertyAndAnnotationCollector, CollectionWithoutExpectedTypeValidator collectionValidator, Boolean validateNullValue, Boolean isTopLevelPropertyValue, Boolean insideResourceValue, String propertyName, Nullable`1 isDynamicProperty)
at Microsoft.OData.ODataUriConversionUtils.ConvertFromResourceOrCollectionValue(String value, IEdmModel model, IEdmTypeReference typeReference)
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.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()
The text was updated successfully, but these errors were encountered:
An NullReferenceException is thrown while parsing a filter expression with the IN operator and a null value for a nullable property.
The problem seems to be related to this line of code:
odata.net/src/Microsoft.OData.Core/UriParser/SemanticAst/CollectionConstantNode.cs
Line 57 in eb0fc9a
If item is NULL, then the call to ToString() will fail with a NullReferenceException.
Assemblies affected
ODataLib 7.5.3
Reproduce steps
Sample Model
Sample query
Expected result
The list of all the TestEntity with 1, 2 or NULL as the value of the property NullablePropertyInt.
Actual result
An NullReferenceException is thrown:
Additional detail
if we try the same query on the non nullable property, we are receiving an ODataException explaining the NULL value is not allowed, which is correct.
The text was updated successfully, but these errors were encountered: