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

1.4.7 Regression -- NullReferenceException from invalid expression instead of ArgumentException #849

Closed
rbell517 opened this issue Oct 28, 2024 · 2 comments
Assignees
Labels

Comments

@rbell517
Copy link

1. Description

In versions 1.4.6 and previous giving invalid expressions would throw ArgumentException or ArgumentNullException, which we could handle accordingly. Instead now a NullReferenceException is thrown, which is bad practice to throw and bad practice to catch.

2. Exception

Exception message: System.NullReferenceException: Object reference not set to an instance of an object.
Stack trace:
   at System.Linq.Dynamic.Core.Parser.ExpressionHelper.GenerateStaticMethodCall(String methodName, Expression left, Expression right)
   at System.Linq.Dynamic.Core.Parser.ExpressionHelper.GenerateGreaterThanEqual(Expression left, Expression right)
   at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseComparisonOperator()
   at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseLogicalAndOrOperator()
   at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseIn()
   at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseOrOperator()
   at System.Linq.Dynamic.Core.DynamicExpressionParser.ParseLambda(Type delegateType, ParsingConfig parsingConfig, Boolean createParameterCtor, ParameterExpression[] parameters, Type resultType, String expression, Object[] values)
   at System.Linq.Dynamic.Core.DynamicExpressionParser.ParseLambda[T,TResult](ParsingConfig parsingConfig, Boolean createParameterCtor, String expression, Object[] values)

3. Fiddle or Project

https://dotnetfiddle.net/sjyNPf

This example uses a numeric operator on a string type, which is invalid and should throw an ArgumentException, but instead throws a NullReferenceException.

Change the nuget version to 1.4.6 to see the expected exception

4. Any further technical details

Valid expressions do not show any regressions.

@StefH StefH self-assigned this Oct 30, 2024
@StefH StefH added the bug label Oct 30, 2024
@StefH
Copy link
Collaborator

StefH commented Oct 30, 2024

#851

@StefH StefH closed this as completed Oct 31, 2024
@rbell517
Copy link
Author

Confirmed the issue is resolved in the new version. Thanks!

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

No branches or pull requests

2 participants