[release/8.0] [Blazor] Allow null
parameter values to be supplied to interactive components via enhanced page update
#53342
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Allow
null
parameter values to be supplied to interactive components via enhanced page updateBackport of #53317
Fixes an issue where a
NullRefrenceException
would be thrown if an enhanced page update supplied anull
parameter to an interactive root component.Description
In .NET 8, SSR'd components can supply updated parameters to existing interactive root components. If one of those updated parameters is
null
, an exception currently gets thrown from within the framework. This causes the circuit to crash when using Server interactivity, and it would causes an error to be logged in the browser console when using WebAssembly interactivity.This PR fixes the problem by treating
null
as a valid value for a serialized parameter that gets supplied to an interactive root component.Fixes #52434
Customer Impact
Without this fix, customers may encounter the unfriendly exception and have a hard time figuring out the underlying cause. We have not yet seen customer reports of the issue, but it's possible that customers have this bug in their apps without knowing it, especially since it only occurs when supplying updated parameters to existing components (not when supplying the initial set of parameters).
One workaround would be to use a different value than
null
to specify an empty parameter value, but this may not be possible in cases where the parameter gets supplied by the framework (e.g., via route value), or if the interactive root component's implementation is not under the developer's control.Regression?
Only applicable to new scenarios in .NET 8.
Risk
The fix is straightforward and well-tested.
Verification
Packaging changes reviewed?