Skip to content

Fix support for unions with null values as root component parameters - #69198

Merged
oroztocil merged 4 commits into
mainfrom
oroztocil/68798-wasm-null-union-parameters
Sep 15, 2026
Merged

oroztocil merged 4 commits into
mainfrom
oroztocil/68798-wasm-null-union-parameters

Conversation

@oroztocil

Copy link
Copy Markdown
Member

Fixes #68798

An interactive-root component parameter whose union active case is null could fail to restore in a fresh WebAssembly runtime. The null-value path called GetTypeInfo before the serializer options had a configured resolver, preventing the component from becoming interactive.

Initialize the options with MakeReadOnly(populateMissingResolver: true) before inspecting union metadata. This follows the normal System.Text.Json initialization behavior while preserving existing null handling and invalid-parameter rejection.

@github-actions github-actions Bot added the area-blazor Includes: Blazor, Razor Components label Sep 10, 2026
@oroztocil
oroztocil requested a balanced review from Copilot September 10, 2026 17:19
@oroztocil
oroztocil marked this pull request as ready for review September 10, 2026 17:19
@oroztocil
oroztocil requested a review from a team as a code owner September 10, 2026 17:19
@oroztocil
oroztocil requested review from DeagleGross and removed request for a team September 10, 2026 17:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The browser-visible cross-runtime regression still needs permanent WebAssembly E2E coverage.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Fixes restoration of active-null union parameters when activating prerendered WebAssembly components.

Changes:

  • Initializes fresh serializer options before union metadata inspection.
  • Injects serializer options into the parameter deserializer.
  • Adds focused union and null-handling tests.
File summaries
File Description
src/Shared/Components/WebAssemblyComponentSerializationSettings.cs Adds an options factory for isolated runtimes and tests.
src/Components/WebAssembly/WebAssembly/src/Prerendering/WebAssemblyComponentParameterDeserializer.cs Configures the resolver before detecting union metadata.
src/Components/WebAssembly/WebAssembly/test/WebAssemblyComponentParameterDeserializerUnionTest.cs Tests fresh-options union restoration and null rejection.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@Youssef1313

Copy link
Copy Markdown
Member

@oroztocil Will you be planning to get this in RC2?

@oroztocil

Copy link
Copy Markdown
Member Author

@Youssef1313 Yes

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 25597002-a307-406a-9236-8704758d4a79
@oroztocil
oroztocil force-pushed the oroztocil/68798-wasm-null-union-parameters branch from 0857580 to 3b16f19 Compare September 11, 2026 13:33
@oroztocil
oroztocil requested a balanced review from Copilot September 11, 2026 13:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused fix preserves existing validation and includes both isolated and browser-level regression coverage.

Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@oroztocil
oroztocil requested a review from a team September 11, 2026 15:21

@DeagleGross DeagleGross left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for quick fix preparation Ondrej!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Cross-runtime serialization, trimming, and WebAssembly behavior warrant final human review despite comprehensive coverage.

Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
};

options.MakeReadOnly(populateMissingResolver: true);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it fair to say this is the actual fix and everything else is for the sake of supporting unit tests?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. The idea is to ensure that the resolver is initialized. Code paths that do Deserialize before GetTypeInfo don't have that problem because Deserialize inits the resolver itself, but GetTypeInfo does not.

To be honest, I am not well acquainted with the area, so if you see a better fix, I would appreciate a hint.

@javiercn javiercn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit extreme to have E2E tests for the null union value. Is there something that the unit tests don't cover?

@oroztocil

oroztocil commented Sep 14, 2026 •

Copy link
Copy Markdown
Member Author

A bit extreme to have E2E tests for the null union value. Is there something that the unit tests don't cover?

@javiercn I had the same opinion so I did not include any E2E tests initially. I added them to not fight the agent instructions in the repo. If you give me the permission to ignore that, I will remove the E2E tests.

@oroztocil
oroztocil enabled auto-merge (squash) September 14, 2026 14:28
@oroztocil
oroztocil disabled auto-merge September 14, 2026 14:51
@oroztocil
oroztocil merged commit ec33757 into main Sep 15, 2026
31 checks passed
@oroztocil
oroztocil deleted the oroztocil/68798-wasm-null-union-parameters branch September 15, 2026 11:56
@oroztocil

Copy link
Copy Markdown
Member Author

/backport to release/11.0

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/11.0 (link to workflow run)

@github-actions

Copy link
Copy Markdown
Contributor

@oroztocil backporting to release/11.0 failed, the patch most likely resulted in conflicts. Please backport manually!

git am output
$ git cherry-pick ec33757f7346be300c356208b3ab2ab141772c2d

Auto-merging src/Components/test/E2ETest/ServerRenderingTests/InteractivityTest.cs
CONFLICT (content): Merge conflict in src/Components/test/E2ETest/ServerRenderingTests/InteractivityTest.cs
error: could not apply ec33757f73... Fix support for unions with null values as root component parameters (#69198)
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
hint: Disable this message with "git config set advice.mergeConflict false"


$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch

Applying: Fix cold WebAssembly restoration of null union parameters
Using index info to reconstruct a base tree...
M	src/Components/test/E2ETest/ServerRenderingTests/InteractivityTest.cs
Falling back to patching base and 3-way merge...
Auto-merging src/Components/test/E2ETest/ServerRenderingTests/InteractivityTest.cs
CONFLICT (content): Merge conflict in src/Components/test/E2ETest/ServerRenderingTests/InteractivityTest.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 Fix cold WebAssembly restoration of null union parameters
Error: The process '/usr/bin/git' failed with exit code 128

Link to workflow output

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

Labels

area-blazor Includes: Blazor, Razor Components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

union keyword: NullableIntOrString with active null fails as interactive-root component parameter in WebAssembly (.NET 11 Preview 7)

5 participants