{"record":{"id":"6a42e61eff568384","repo":"PrismLibrary/Prism","slug":"invalid-tab-name-tabname","errorCode":null,"errorMessage":"Invalid Tab Name: {tabName}","messagePattern":"Invalid Tab Name: (.+?)","errorType":"exception","errorClass":"NavigationException","httpStatus":null,"severity":"error","filePath":"src/Maui/Prism.Maui/Navigation/PageNavigationService.cs","lineNumber":397,"sourceCode":"            {\n                var tabRegistration = Registry.Registrations.FirstOrDefault(x => x.Name == tabName);\n                selectedChild = tabbedPage.Children.FirstOrDefault(x =>\n                    ViewModelLocator.GetNavigationName(x) == tabName\n                    || (x is NavigationPage navPage && ViewModelLocator.GetNavigationName(navPage.RootPage) == tabName)\n                    || (tabRegistration is not null && x is NavigationPage np && IsPage(np.RootPage, tabRegistration, tabName))\n                    || (tabRegistration is not null && IsPage(x, tabRegistration, tabName)));\n            }\n            else if (parts.Length == 2)\n            {\n                var rootRegistration = Registry.Registrations.FirstOrDefault(x => x.Name == parts[0]);\n                var leafRegistration = Registry.Registrations.FirstOrDefault(x => x.Name == parts[1]);\n                selectedChild = tabbedPage.Children.FirstOrDefault(x =>\n                    x is NavigationPage navPage\n                    && (ViewModelLocator.GetNavigationName(navPage) == parts[0] || (rootRegistration is not null && IsPage(navPage, rootRegistration, parts[0])))\n                    && (ViewModelLocator.GetNavigationName(navPage.RootPage) == parts[1] || (leafRegistration is not null && IsPage(navPage.RootPage, leafRegistration, parts[1]))));\n            }\n            else\n                throw new NavigationException($\"Invalid Tab Name: {tabName}\");\n\n            if (selectedChild is null)\n                throw new NavigationException($\"No Tab found with the Name: {tabName}\");\n\n            var navigatedFromPage = _pageAccessor.Page;\n            if (!await MvvmHelpers.CanNavigateAsync(navigatedFromPage, parameters))\n                throw new NavigationException(NavigationException.IConfirmNavigationReturnedFalse, navigatedFromPage);\n\n            var navigatedToTarget = selectedChild is NavigationPage navPage ? navPage.CurrentPage : selectedChild;\n            if (uri is not null)\n            {\n                if (uri.IsAbsoluteUri)\n                {\n                    throw new NavigationException(\"Cannot process an absolute Navigation Uri when navigating within a specified Tab\");\n                }\n\n                var navigationSegments = UriParsingHelper.GetUriSegments(uri);\n                await ProcessNavigation(navigatedToTarget, navigationSegments, parameters, null, null);","sourceCodeStart":379,"sourceCodeEnd":415,"githubUrl":"https://github.com/PrismLibrary/Prism/blob/358118cd640d9a22ff8cf21c8ad197fa038b7990/src/Maui/Prism.Maui/Navigation/PageNavigationService.cs#L379-L415","documentation":"SelectTabAsync parses the tabName using '|' as a separator; exactly one part means a direct tab and two parts mean a NavigationPage child ('root|leaf'). If the string contains more than one '|' (or is otherwise malformed so parts.Length is neither 1 nor 2), the method throws NavigationException('Invalid Tab Name: {tabName}').","triggerScenarios":"Passing a tab name with two or more '|' separators, e.g. \"A|B|C\"; passing a fully qualified URI by mistake where SelectTabAsync expects the short tab-name syntax.","commonSituations":"Copy-pasting a deep-link URI ('TabbedPage/A|B') into SelectTabAsync instead of just the tab segment; building names dynamically and joining too many segments; confusion between NavigateAsync URI syntax and SelectTabAsync name syntax.","solutions":["Pass a name with at most one '|' (e.g. \"TabName\" or \"NavPage|ChildPage\").","Strip the TabbedPage prefix from a deep-link URI and pass only the tab segment.","Validate/split the name yourself before calling, and throw a clearer app-level error for malformed input.","Use NavigateAsync with the full URI if you actually need multi-segment navigation."],"exampleFix":"// before\nawait _navigationService.SelectTabAsync(\"TabbedPage/NavPage|Child|Extra\");\n// after\nawait _navigationService.SelectTabAsync(\"NavPage|Child\");","handlingStrategy":"validation","validationCode":"var parts = tabName.Split('|');\nif (parts.Length is not (1 or 2))\n    throw new ArgumentException($\"Tab name must be 'tab' or 'navRoot|leaf': {tabName}\");","typeGuard":"bool IsValidTabName(string tabName) =>\n    !string.IsNullOrWhiteSpace(tabName) && tabName.Split('|').Length is 1 or 2;","tryCatchPattern":"try { await _navigationService.SelectTabAsync(tabName); }\ncatch (NavigationException ex) when (ex.Message.StartsWith(\"Invalid Tab Name\"))\n{ /* fix name or fall back to NavigateAsync */ }","preventionTips":["Use at most one '|' in tab names","Keep tab-name construction in one constant/helper, never inline strings","Use NavigateAsync URIs for multi-segment navigation instead of SelectTabAsync"],"tags":["navigation","tabbedpage","invalid-argument","prism","xamarin-maui"],"backgroundTag":"invalid-argument-format","analyzedSha":"358118cd640d9a22ff8cf21c8ad197fa038b7990","analyzedAt":"2026-09-15T15:00:31.079Z","contentChangedAt":"2026-09-15T15:00:31.079Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}