Skip to content

Context is undefined when search validation fails #1656

Closed

Description

@geoff-harper

Describe the bug

I've discovered that the missing context bug isn't fully fixed in 1.33.7. Also sorry for sort of spamming the other closed issue, I thought I'd open a new one.

I'm not completely sure of what's triggering it or if there's more cases but these are the steps in my own app

  1. open a route with no search validation (not sure this part is relevant)
  2. directly enter a route into the address bar that has search validation, but don't include any search params in the address
  3. navigate to the route, context should be undefined

My schema catches and fills values like the docs suggest. In step 3 when the error component is fired, it does still put the caught values into the url. I broke the validateSearch method into pieces instead of directly returning a schema, and it specifically fails when anything is returned in the method.

Your Example Website or App

https://stackblitz.com/edit/github-spzf56-us3fam?file=src%2Froutes%2F_layout.index.tsx

Steps to Reproduce the Bug or Issue

  1. Go to the about route
  2. Go to index route through address bar, omit search params

Expected behavior

Context should be defined in all cases

Screenshots or Videos

No response

Platform

  • Browser: all
  • Version: 1.33.7

Additional context

No response

Activity

  1. melv-n commented on Jun 3, 2024

    @melv-n
    Contributor

    I found this in v1.34.9 as well, causing context to become undefined if the route that throws the redirect has search params that are being validated through validateSearch, and the validation fails/throws (e.g. with zod).

    Here's a complete repro:
    https://stackblitz.com/edit/tanstack-router-qbczsv?file=src%2Froutes%2Findex.tsx

  2. added
    bug
    on Jun 12, 2024
  3. schiller-manuel commented on Jul 6, 2024

    @schiller-manuel
    Collaborator
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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions