{"record":{"id":"603890419bbde35c","repo":"dotnet/maui","slug":"unexpected-navigation-type","errorCode":null,"errorMessage":"Unexpected navigation type","messagePattern":"Unexpected navigation type","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellItemRendererBase.cs","lineNumber":195,"sourceCode":"\t\t\t\t\tif (!isForCurrentTab && removeFragment != _currentFragment)\n\t\t\t\t\t\treturn Task.FromResult(true);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase ShellNavigationSource.PopToRoot:\n\t\t\t\t\tRemoveAllPushedPages(shellSection, isForCurrentTab);\n\t\t\t\t\tif (!isForCurrentTab)\n\t\t\t\t\t\treturn Task.FromResult(true);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase ShellNavigationSource.ShellSectionChanged:\n\t\t\t\t\t// We need to handle this after we know what the target is\n\t\t\t\t\t// because we might accidentally remove an already added target.\n\t\t\t\t\t// Then there would be two transactions in a row, one removing and one adding\n\t\t\t\t\t// the same fragment and things get really screwy when you do that.\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new InvalidOperationException(\"Unexpected navigation type\");\n\t\t\t}\n\n\t\t\tIReadOnlyList<Page> stack = ShellSection.Stack;\n\t\t\tElement targetElement = null;\n\t\t\tIShellObservableFragment target = null;\n\t\t\tif (stack.Count == 1 || navSource == ShellNavigationSource.PopToRoot)\n\t\t\t{\n\t\t\t\ttarget = _fragmentMap[ShellSection];\n\t\t\t\ttargetElement = ShellSection;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\ttargetElement = stack[stack.Count - 1];\n\t\t\t\tif (!_fragmentMap.ContainsKey(targetElement))\n\t\t\t\t\t_fragmentMap[targetElement] = CreateFragmentForPage(targetElement as Page);\n\t\t\t\ttarget = _fragmentMap[targetElement];\n\t\t\t}\n","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellItemRendererBase.cs#L177-L213","documentation":"Thrown by the Android ShellItemRendererBase in its navigation handling switch statement. The switch covers known ShellNavigationSource values (Insert, Remove, Push, Pop, PopToRoot, ShellSectionChanged) and the default case throws InvalidOperationException for any unrecognized navigation source. This means a navigation request was initiated with a ShellNavigationSource value the renderer does not know how to process, which typically indicates a framework version mismatch or a custom/extension navigation source.","triggerScenarios":"At the `default:` case of the switch on `navSource` (ShellNavigationSource). Triggered when ShellSection.OnNavigateAsync or equivalent passes a ShellNavigationSource enum value not covered by the switch cases. This could be a future enum value, a custom enum value injected via reflection or a custom Shell implementation, or an internal navigation path that was added to the enum but not to this renderer's switch.","commonSituations":"1) Using a pre-release or nightly MAUI build where a new ShellNavigationSource was added to the enum but renderer handling wasn't updated. 2) Custom Shell subclass that injects non-standard navigation requests. 3) Version mismatch between the MAUI NuGet package and a compatibility/extension library that uses different navigation sources. 4) Extremely rare — a framework regression where an internal navigation path uses an uncovered source.","solutions":["If using a pre-release MAUI build, update to a stable release or a newer build that has matching renderer support for all ShellNavigationSource values.","Check that no custom Shell subclass or third-party library is injecting non-standard ShellNavigationSource values into navigation requests.","File a bug report with the MAUI team including the exact ShellNavigationSource value that triggered the default case (add logging before the switch to capture navSource.ToString()).","Ensure MAUI NuGet packages are all at the same version across the solution to avoid enum definition mismatches."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Log navigation source for debugging\nvar navSource = (e.Request as ShellNavigationRequest)?.Source;\n// Known sources: Insert, Remove, Push, Pop, PopToRoot, ShellSectionChanged","typeGuard":null,"tryCatchPattern":"try { await Shell.Current.GoToAsync(route); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Unexpected navigation type\"))\n{\n    // Framework/navigation source mismatch — log and report\n    // Likely a version mismatch between MAUI packages","preventionTips":["Keep all MAUI NuGet packages at the same version across the solution.","Avoid custom Shell subclasses that inject non-standard navigation sources.","Use stable MAUI releases in production."],"tags":["maui","android","shell","navigation","renderer"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}