[CSHARP-4521] Handle parameterName empty string the same as null Created: 09/Feb/23 Updated: 28/Oct/23 Resolved: 14/Feb/23 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | LINQ3 |
| Affects Version/s: | 2.19.0 |
| Fix Version/s: | 2.19.1 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Andy Bennett | Assignee: | Robert Stam |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | Bug | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Documentation Changes: | Not Needed |
| Documentation Changes Summary: | 1. What would you like to communicate to the user about this feature? |
| Description |
| Comments |
| Comment by Githook User [ 24/Mar/23 ] | |||||||||||||||||
|
Author: {'name': 'rstam', 'email': 'robert@robertstam.org', 'username': 'rstam'}Message: | |||||||||||||||||
| Comment by Githook User [ 14/Feb/23 ] | |||||||||||||||||
|
Author: {'name': 'rstam', 'email': 'robert@robertstam.org', 'username': 'rstam'}Message: | |||||||||||||||||
| Comment by Andy Bennett [ 10/Feb/23 ] | |||||||||||||||||
|
Many thanks, Robert. | |||||||||||||||||
| Comment by Robert Stam [ 09/Feb/23 ] | |||||||||||||||||
|
The repro is getting kind of complicated... Knowing that you are using dynamic LINQ and looking at the stack trace, I've determined that the problem is that dynamic LINQ is using an empty string as the parameter name. We have code to handle a null as the parameter name, but not the empty string. I've reproduced your issue (but not using any of your code) and have a fix for it. Thanks again for reporting this. | |||||||||||||||||
| Comment by Andy Bennett [ 09/Feb/23 ] | |||||||||||||||||
|
You are correct, 'filter' is a string that is dynamically constructed. I am using the 'Where' from System.Linq.Dynamic.Core which can consume a string. I did not intend it to be a C# expression. 'data' is of type IQueryable<T> data OptionalTake is shown below. Hope that helpd. If not, I willl attempt to create a standalone console application next week. PS. I'm using a string rather than an expression because our UI components use a string based notation for filtering.
| |||||||||||||||||
| Comment by Robert Stam [ 09/Feb/23 ] | |||||||||||||||||
|
Thanks for the additional information. The `filter` looks odd. It's a `string` but it looks like you intended it to be a C# expression. Also, where is `data` defined? Or `OptionalTake`? It might be better if you created a standalone console application that I can compile and run and base my repro on. | |||||||||||||||||
| Comment by Andy Bennett [ 09/Feb/23 ] | |||||||||||||||||
|
Thanks Robert. The 'Where' code is as follows:
I understand this may be data related, but the same code worked with the same data under v2.18. | |||||||||||||||||
| Comment by Robert Stam [ 09/Feb/23 ] | |||||||||||||||||
|
I have been unable to reproduce this. You could look at my attempt here: https://github.com/rstam/mongo-csharp-driver/tree/csharp4521 Maybe you could take a look and tell me if I missed something. The stack trace you reported indicates that the exception was thrown while translating a `Where` method, so you probably need to show me how you were calling `Where`. | |||||||||||||||||
| Comment by Robert Stam [ 09/Feb/23 ] | |||||||||||||||||
|
Thank you for reporting this issue. I will begin investigating it soon. |