ValueProvider array of strings having a null value is processed wrong
See original GitHub issueIs there an existing issue for this?
- I have searched the existing issues
Describe the bug
public class SomeValueProvider : IValueProvider
{
public bool ContainsPrefix(string prefix)
{
return true;
}
public ValueProviderResult GetValue(string key)
{
return new ValueProviderResult(new string[] { "a", "b", null, "c" });
}
}
Controller method
public async Task<IActionResult> Index(List<string> list)
{
await Task.Yield();
// Returned list "a", b", "b", "c"
// Expected list "a", b", null, "c"
return Content("<pre>returns "+string.Join(",", list)+ " expected a,b,,c</pre>", "text/html");
}
Expected Behavior
When using an Array of strings having null values in it, it must not skip, nor must it repeat previous element values.
Steps To Reproduce
The bug is visible in this small test project:
https://github.com/alphons/ValueProviderBug
Exceptions (if any)
No exceptions, bug procudes wrong processing of Array elements having null values.
.NET Version
6.0.102
Anything else?
ASP.NET 6.0.2
Issue Analytics
- State:
- Created a year ago
- Comments:15 (9 by maintainers)
Top Results From Across the Web
Value Provider Path null issue GXT 3.0 - java
In GXT 3.0, valueProvider, I have a null pointer exception issue. I have this code snippet, @Path("xxx.yyy") ValueProvider<User, String> zzz() ...
Read more >Model Binding in ASP.NET Core
The sample includes a value provider and factory example that gets values ... the model property has been set to null or a...
Read more >How to fix the null index array error in powershell?
I am trying to run a PowerShell script which is taking three input PAT, organization and connection string of the database.
Read more >Avoid Check for Null Statement in Java
Learn several strategies for avoiding the all-too-familiar boilerplate conditional statements to check for null values in Java.
Read more >Creating classic Dataflow templates
You can use isAccessible() to check if the value of a ValueProvider is available. If you call get() before pipeline execution, Apache Beam...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
To elaborate on the null values, and a read-world (?!) example … Maybe in forms or querystring request strings null has no much of a meaning, but when posting json data to a MVC controller, and binding its parameters, we have to use the famous ValueProviderResult. And string.Empty has a complete different meaning then null. Turning string.Empty into null has also devastating effects, mostly gaining nothing, i call it a weird feature or artifact.
Here is some of my javascript code, which posts json to a controller. It can be bind to method parameters, if we all want it 😉 netproxy is a simple javascript function to make json post calls to an url. Source …/wwwroot/Scripts/netproxy.js
To this controller method:
Results in the repeat bug: 1.2, 3.4, 5.6, 5.6, 7.8
Concluding, for having nullable values, this means also nullable strings, but also empty strings, and they are, clearly, not the same.
Let’s keep this issue open for now.