[Settings] Stop fail-fast in ShellViewModel.Frame_NavigationFailed#48409
Open
crutkas wants to merge 1 commit into
Open
[Settings] Stop fail-fast in ShellViewModel.Frame_NavigationFailed#48409crutkas wants to merge 1 commit into
crutkas wants to merge 1 commit into
Conversation
Re-throwing from a NavigationFailed handler propagates back through the WinRT marshalling layer as a stowed exception and FailFasts the Settings process. e.Exception can also be null in some failure paths, immediately yielding a NullReferenceException on the throw itself. Mark the failure handled, log it via ManagedCommon.Logger, and null-safely format the source page name. Add Settings.UI.UnitTests coverage for the null-safe formatter. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Jun 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
ShellViewModel.Frame_NavigationFailedunconditionally re-threwe.Exception. When the WinUIFrameraisesNavigationFailed, throwing back from the handler propagates through the WinRT marshalling layer as a stowed exception and the runtime tears the process down viaRoFailFastWithErrorContextInternal2- Settings crashes instead of surfacing a recoverable error.e.Exceptioncan also be null in some failure paths (e.g., the requested page type cannot be resolved), in which case the previous code immediately raised aNullReferenceExceptionon the throw statement itself.This was spotted while reading through
ShellViewModelfor an unrelated review.Fix
e.Handled = trueso WinUI does not fail-fast.Logger.LogError(...)(the existing house pattern viaManagedCommon) to record the navigation failure with the source page name and exception, so it still shows up in PowerToys logs for diagnosis.SourcePageTypeby extractingGetPageDisplayNameand falling back to"<unknown>".Exceptionby calling theLogError(string)overload in that case.Tests
Added
ShellViewModelTestsunderSettings.UI.UnitTestscovering both branches ofGetPageDisplayName:Type-> returnsFullNamenull-> returns<unknown>(no NRE)Both pass locally (
dotnet test ... --filter ShellViewModelTests).Validation
MSBuild PowerToys.Settings.csproj /p:Configuration=Release /p:Platform=x64builds.MSBuild Settings.UI.UnitTests.csprojbuilds.Notes
Frame_NavigationFailedinNavigationService.csis justNavigationFailed?.Invoke(sender, e);so it does not need changes - the fix is on the actual subscriber.