Skip to content

notFound in parameter parser returns 500, not 404 #5733

Description

@matt-thomson

Which project does this relate to?

Router

Describe the bug

I have a parse function for path parameters, which throws a notFound error when the parameters aren't in the required format. For example:

export const Route = createFileRoute('/$id')({
  component: Home,
  params: {
    parse: ({ id }) => {
      const parsedId = parseInt(id, 10);

      if (Number.isNaN(parsedId)) {
        throw notFound();
      }

      return { id: parsedId };
    }
  },
  notFoundComponent: () => <div>Page not found</div>
})

However, this leads to a 500 error, not the 404 that I'd expect. Is this the correct behaviour or a bug? If it's expected, is there a way to get the 404 in this case?

See full example in this repository. I asked about this in the Discord here and was recommended to create this issue.

Your Example Website or App

https://github.com/matt-thomson/tanstack-validate-not-found/

Steps to Reproduce the Bug or Issue

See above

Expected behavior

I expect to see a 404 error, but instead I get a 500.

Screenshots or Videos

No response

Platform

  • Router / Start Version: 1.134.9
  • OS: Linux
  • Browser: Firefox
  • Browser Version: 144.0.2
  • Bundler: vite
  • Bundler Version: 7.1.7

Additional context

No response

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions