{"record":{"id":"5e6fc6c4167c0f46","repo":"PrismLibrary/Prism","slug":"navigationcallback","errorCode":null,"errorMessage":"navigationCallback","messagePattern":"navigationCallback","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Maui/Prism.Maui/Navigation/Regions/Navigation/RegionNavigationService.cs","lineNumber":91,"sourceCode":"    /// Initiates navigation to the specified target.\n    /// </summary>\n    /// <param name=\"target\">The target.</param>\n    /// <param name=\"navigationCallback\">A callback to execute when the navigation request is completed.</param>\n    public void RequestNavigate(Uri target, Action<NavigationResult> navigationCallback)\n    {\n        RequestNavigate(target, navigationCallback, null);\n    }\n\n    /// <summary>\n    /// Initiates navigation to the specified target.\n    /// </summary>\n    /// <param name=\"target\">The target.</param>\n    /// <param name=\"navigationCallback\">A callback to execute when the navigation request is completed.</param>\n    /// <param name=\"regionParameters\">The navigation parameters specific to the navigation request.</param>\n    public void RequestNavigate(Uri target, Action<NavigationResult> navigationCallback, INavigationParameters regionParameters)\n    {\n        if (navigationCallback == null)\n            throw new ArgumentNullException(nameof(navigationCallback));\n\n        try\n        {\n            DoNavigate(target, navigationCallback, regionParameters);\n        }\n        catch (Exception e)\n        {\n            NotifyNavigationFailed(new NavigationContext(this, target), navigationCallback, e);\n        }\n    }\n\n    private void DoNavigate(Uri source, Action<NavigationResult> navigationCallback, INavigationParameters regionParameters)\n    {\n        if (source == null)\n            throw new ArgumentNullException(nameof(source));\n\n        if (Region == null)\n            throw new InvalidOperationException(Resources.NavigationServiceHasNoRegion);","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/PrismLibrary/Prism/blob/358118cd640d9a22ff8cf21c8ad197fa038b7990/src/Maui/Prism.Maui/Navigation/Regions/Navigation/RegionNavigationService.cs#L73-L109","documentation":"RequestNavigate validates that the completion callback is non-null before starting navigation, because the NavigationResult must be delivered back to the caller. A null callback makes the asynchronous navigation result unobservable, so Prism throws immediately rather than navigating silently.","triggerScenarios":"Calling region.NavigationService.RequestNavigate(uri, null) or forwarding a callback variable that is null (e.g. an unassigned Action<NavigationResult>).","commonSituations":"Wrapping navigation in helper methods with an optional callback parameter that is passed straight through; refactoring that dropped the callback lambda.","solutions":["Pass a non-null callback, even a no-op: result => { }.","In helper wrappers, substitute an empty lambda when the caller supplies none.","Guard the callback at the call site before invoking RequestNavigate."],"exampleFix":"// before\nnavigationService.RequestNavigate(new Uri(\"DetailsView\", UriKind.Relative), null);\n// after\nnavigationService.RequestNavigate(new Uri(\"DetailsView\", UriKind.Relative), result => { });","handlingStrategy":"try-catch","validationCode":"if (navigationCallback is null)\n    navigationCallback = result => { };\nnavigationService.RequestNavigate(target, navigationCallback, parameters);","typeGuard":"bool HasCallback(Action<NavigationResult> cb) => cb is not null;","tryCatchPattern":"try\n{\n    navigationService.RequestNavigate(target, result => OnNavigated(result));\n}\ncatch (ArgumentNullException)\n{\n    // supply a callback and retry\n}","preventionTips":["Always pass a result handler lambda, even an empty one.","Wrap navigation in a helper that substitutes a no-op callback.","Treat Action<NavigationResult> parameters as required, not optional."],"tags":["null-argument","navigation","callback","prism"],"backgroundTag":"null-argument","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"}