Skip to content

[go_router] Cannot distinguish a blocked initial deep link from other routing errors in onException #189581

Closed
flutter/packages
#12213

Description

@davidmigloz

Use case

Apps using onEnter for async guards (entitlements, permissions, feature flags) sometimes need to block the very first navigation — e.g. a deep link on web arrives before the guard's data is cached, so onEnter returns Block.stop().

When that happens there is no prior route to restore, and the parser reports a generic GoException('Navigation to ... was blocked by onEnter with no prior route to restore') through onException. The app wants to recover differently depending on the cause: redirect a blocked deep link to a loading screen with the original location preserved, but send genuine 404s and other routing errors to a fallback screen. Today the only way to tell them apart is string matching on the exception message, which breaks silently if the message ever changes.

Proposal

Add a typed BlockedInitialNavigationException extends GoException, raised in that specific code path. Existing is GoException checks keep working; apps can opt into if (state.error is BlockedInitialNavigationException) in onException.

Activity

  1. added
    c: new featureNothing broken; request for a new capability
    f: routesNavigator, Router, and related APIs.
    packageflutter/packages repository. See also p: labels.
    c: proposalA detailed proposal for a change to Flutter
    on Jul 16, 2026
  2. mbcorona commented on Jul 16, 2026

    @mbcorona
    Member

    Thanks for the proposal and linked PR.
    Routing to the framework team; PR flutter/packages#12213 is linked. Related to #189582.

  3. added a commit that references this issue on Jul 29, 2026
    1448f08
  4. github-actions commented on Aug 12, 2026

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  5. locked as resolved and limited conversation to collaborators on Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterf: routesNavigator, Router, and related APIs.p: go_routerThe go_router packagepackageflutter/packages repository. See also p: labels.team-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework teamwaiting for PR to land (fixed)A fix is in flight

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions