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
Using dynamic linq to filter results in API GET requests. Initially, everything works just fine, after some time, a .Contains filter on a string property starts returning an error.
Example query that works for a while and then eventually fails:
The extra parentheses are coming from a process that builds the query based on the URL Query Parameters passed into the API call. And args is technically coming in as a parameter in the method call. This happens for any object and any string field on the object used.
I first started noticing this happen in version 1.3.10 and am still seeing it in 1.4.0. The last version I have not seen this happen with was 1.3.8. I have not tested 1.3.9.
2. Exception
Exception message: System.InvalidOperationException": "No generic method 'Contains' on type 'System.Linq.Enumerable' is compatible with the supplied type arguments and arguments. No type arguments should be provided if the method is non-generic.
Stack trace: at System.Linq.Expressions.Expression.FindMethod(Type type, String methodName, Type[] typeArgs, Expression[] args, BindingFlags flags)
at System.Linq.Dynamic.Core.Parser.ExpressionParser.TryParseEnumerable(Expression instance, Type elementType, String methodName, Int32 errorPos, Type type, Expression[]& args, Expression& expression)
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseMemberAccess(Type type, Expression expression, String id)
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParsePrimary()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseUnary()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseArithmetic()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseAdditive()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseShiftOperator()
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.ParseConditionalOperator()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseParenExpression()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParsePrimary()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseUnary()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseArithmetic()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseAdditive()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseShiftOperator()
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.ParseConditionalOperator()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseParenExpression()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParsePrimary()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseUnary()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseArithmetic()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseAdditive()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseShiftOperator()
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.ParseConditionalOperator()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseParenExpression()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParsePrimary()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseUnary()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseArithmetic()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseAdditive()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseShiftOperator()
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.ParseConditionalOperator()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.Parse(Type resultType, Boolean createParameterCtor)
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(ParsingConfig parsingConfig, Boolean createParameterCtor, ParameterExpression[] parameters, Type resultType, String expression, Object[] values)
at System.Linq.Dynamic.Core.DynamicExpressionParser.ParseLambda(ParsingConfig parsingConfig, Boolean createParameterCtor, Type itType, Type resultType, String expression, Object[] values)
at System.Linq.Dynamic.Core.DynamicQueryableExtensions.Where(IQueryable source, ParsingConfig config, String predicate, Object[] args)
at System.Linq.Dynamic.Core.DynamicQueryableExtensions.Where[TSource](IQueryable`1 source, ParsingConfig config, String predicate, Object[] args)
at System.Linq.Dynamic.Core.DynamicQueryableExtensions.Where[TSource](IQueryable`1 source, String predicate, Object[] args)
3. Fiddle or Project
I have not been able to fail this in a test project. I have had a simple test project running for the past week running dynaimc linq queries every 50ms which has still not failed. My simple test project has been running in an Ubuntu VM on a Windows host.
4. Any further technical details
This is happening on a .NET 8 MVC application running on Rocky Linux. Restarting the .NET application does fix it for a time. It feels like there is some kind of shared state corruption happening or something. But looking through both my production code and this project, I haven't found any shared or persisted state that would apply.
Once the errors start happening, they happen on every subsequent query that attempts to filter on a string property until the app is restarted. It typically takes somewhere in the range of 18-36 hours after app restart before the failures start being reported.
I have found that I can get the same call stack if I change the data type of a property from string to IEnumerable<char>, so one possible explanation is that once the failure state starts happening, it mistakenly treats string types as IEnumerabe<char>.
Some weeks ago, I did notice some of my unit tests failing when I updated to 1.3.10 and they fixed themselves when I reverted back to 1.3.8. Strangely, the unit tests now pass when I use 1.3.10 or higher.
The text was updated successfully, but these errors were encountered:
1. Description
Using dynamic linq to filter results in API GET requests. Initially, everything works just fine, after some time, a .Contains filter on a string property starts returning an error.
Example query that works for a while and then eventually fails:
The extra parentheses are coming from a process that builds the query based on the URL Query Parameters passed into the API call. And args is technically coming in as a parameter in the method call. This happens for any object and any string field on the object used.
I first started noticing this happen in version 1.3.10 and am still seeing it in 1.4.0. The last version I have not seen this happen with was 1.3.8. I have not tested 1.3.9.
2. Exception
3. Fiddle or Project
I have not been able to fail this in a test project. I have had a simple test project running for the past week running dynaimc linq queries every 50ms which has still not failed. My simple test project has been running in an Ubuntu VM on a Windows host.
4. Any further technical details
This is happening on a .NET 8 MVC application running on Rocky Linux. Restarting the .NET application does fix it for a time. It feels like there is some kind of shared state corruption happening or something. But looking through both my production code and this project, I haven't found any shared or persisted state that would apply.
Once the errors start happening, they happen on every subsequent query that attempts to filter on a string property until the app is restarted. It typically takes somewhere in the range of 18-36 hours after app restart before the failures start being reported.
I have found that I can get the same call stack if I change the data type of a property from
string
toIEnumerable<char>
, so one possible explanation is that once the failure state starts happening, it mistakenly treatsstring
types asIEnumerabe<char>
.Some weeks ago, I did notice some of my unit tests failing when I updated to 1.3.10 and they fixed themselves when I reverted back to 1.3.8. Strangely, the unit tests now pass when I use 1.3.10 or higher.
The text was updated successfully, but these errors were encountered: