Skip to content

Conversation

@Sheraff
Copy link
Contributor

@Sheraff Sheraff commented Jan 24, 2026

Fixes #6490

Warning

I'm not 100% convinced this is a good idea.

Possible issues:

  • slower than not doing it
  • sometimes people pre-interpolate their to props, and then it wouldn't match anything in the routesByPath lookup
  • sometimes once interpolated, the pathname will actually match another route than the original to (intended behavior) but by then we will have stringified the params using the original to (weird behavior?)
  • aren't there other places in the codebase where we just encodeURIComponent the params instead of going through params.stringify? I have a hard time believing we always know which route branch we're working on
  • ??

However, if you respect the types, and you don't have a crazy route setup that makes conflict likely, then this is pretty powerful (see original issue).

The alternatives are:

  • to simply forbid the combined use of skipRouteOnParseError.params: true and params.stringify
  • to use a separate method for skipRouteOnParseError.params than the one used for "reversing the stringification"

🤷

Summary by CodeRabbit

  • New Features

    • Route-building utility is now publicly available for external use.
  • Improvements

    • Improved path interpolation when route parameters use custom parse/stringify, ensuring correct pathname output even when parse errors are configured to skip a route.
  • Tests

    • Added tests covering parameter stringification and skip-on-parse-error behavior to validate route resolution outcomes.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 24, 2026

📝 Walkthrough

Walkthrough

Exports buildRouteBranch from the route-tree module and adds a pre-interpolation parameter stringification pass in buildLocation (using route branch stringifiers) with new tests covering skipRouteOnParseError behavior.

Changes

Cohort / File(s) Summary
Route Tree Module Export
packages/router-core/src/new-process-route-tree.ts
Adds export to buildRouteBranch, making it part of the module's public API.
Parameter Stringification Preprocessing
packages/router-core/src/router.ts
Imports buildRouteBranch and introduces prestringifiedParams flow: pre-stringify params across a route branch when skipRouteOnParseError.params is set, use those params for interpolatePath, and fall back to recomputing stringification when destination mismatches.
Test Coverage
packages/router-core/tests/build-location.test.ts
Adds tests validating buildLocation yields expected pathname with custom parse/stringify and skipRouteOnParseError configured for params.

Sequence Diagram(s)

sequenceDiagram
  participant Router as Router.buildLocation
  participant Branch as buildRouteBranch
  participant Route as Route.stringify
  participant Interp as interpolatePath
  participant Dest as DestinationResolver

  Router->>Branch: request branch for target route
  Branch-->>Router: route branch (stringifiers)
  Router->>Route: apply stringify across branch -> prestringifiedParams
  Route-->>Router: prestringifiedParams
  Router->>Interp: interpolatePath(nextTo, prestringifiedParams, decoder)
  Interp-->>Router: interpolatedNextTo
  Router->>Dest: resolve destination with interpolatedNextTo
  Dest-->>Router: resolved destination (fullPath)
  alt destination matches trimmed target
    Router->>Router: use interpolatedNextTo as nextPathname
  else destination mismatch
    Router->>Route: compute stringifiedParams fallback
    Route-->>Router: stringifiedParams
    Router->>Interp: interpolatePath(nextTo, stringifiedParams)
    Interp-->>Router: nextPathname
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Suggested reviewers

  • schiller-manuel
  • nlynzaad

Poem

🐰 I hopped the branch and called each name,
I dressed the params before the game,
So paths sing true and routes align,
I tuck their strings, one hop in time,
Hooray — the URL looks fine! 🌿

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the primary fix: buildLocation now uses stringified params when interpolating paths for routes with skipRouteOnParseError configuration.
Linked Issues check ✅ Passed The PR directly addresses issue #6490 by implementing the required fix: stringified params are now applied during interpolatePath for skipRouteOnParseError routes, preserving custom parse/stringify flows.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the skipRouteOnParseError stringification issue: exporting buildRouteBranch, implementing prestringifiedParams logic in buildLocation, and adding comprehensive test coverage.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud
Copy link

nx-cloud bot commented Jan 24, 2026

View your CI Pipeline Execution ↗ for commit 6f09b9f

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ✅ Succeeded 9m 17s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 1m 41s View ↗

☁️ Nx Cloud last updated this comment at 2026-01-24 17:22:52 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 24, 2026

More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/arktype-adapter@6491

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/eslint-plugin-router@6491

@tanstack/history

npm i https://pkg.pr.new/TanStack/router/@tanstack/history@6491

@tanstack/nitro-v2-vite-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/nitro-v2-vite-plugin@6491

@tanstack/react-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router@6491

@tanstack/react-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-devtools@6491

@tanstack/react-router-ssr-query

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-ssr-query@6491

@tanstack/react-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start@6491

@tanstack/react-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-client@6491

@tanstack/react-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-server@6491

@tanstack/router-cli

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-cli@6491

@tanstack/router-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-core@6491

@tanstack/router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools@6491

@tanstack/router-devtools-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools-core@6491

@tanstack/router-generator

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-generator@6491

@tanstack/router-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-plugin@6491

@tanstack/router-ssr-query-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-ssr-query-core@6491

@tanstack/router-utils

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-utils@6491

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-vite-plugin@6491

@tanstack/solid-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router@6491

@tanstack/solid-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-devtools@6491

@tanstack/solid-router-ssr-query

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-ssr-query@6491

@tanstack/solid-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start@6491

@tanstack/solid-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-client@6491

@tanstack/solid-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-server@6491

@tanstack/start-client-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-client-core@6491

@tanstack/start-fn-stubs

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-fn-stubs@6491

@tanstack/start-plugin-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-plugin-core@6491

@tanstack/start-server-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-core@6491

@tanstack/start-static-server-functions

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-static-server-functions@6491

@tanstack/start-storage-context

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-storage-context@6491

@tanstack/valibot-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/valibot-adapter@6491

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/TanStack/router/@tanstack/virtual-file-routes@6491

@tanstack/vue-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-router@6491

@tanstack/vue-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-router-devtools@6491

@tanstack/vue-router-ssr-query

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-router-ssr-query@6491

@tanstack/vue-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start@6491

@tanstack/vue-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start-client@6491

@tanstack/vue-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start-server@6491

@tanstack/zod-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/zod-adapter@6491

commit: 6f09b9f

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@packages/router-core/src/router.ts`:
- Around line 1803-1807: The interpolatedNextTo is currently built from
nextParams (parsed values) but later code sometimes needs the stringified values
in prestringifiedParams; change the interpolation so that when
prestringifiedParams is provided you call interpolatePath with params:
prestringifiedParams (and same decoder) instead of nextParams, or alternatively
compute a second value (e.g., interpolatedPrestringifiedNextTo) by calling
interpolatePath({ path: nextTo, params: prestringifiedParams, decoder:
this.pathParamsDecoder }) and use that result wherever the code currently
branches on prestringifiedParams (including the return path and any route
matching that relies on interpolatedNextTo). Ensure the unique symbols involved
are interpolatePath, interpolatedNextTo (or new
interpolatedPrestringifiedNextTo), nextParams, and prestringifiedParams so the
correct interpolated pathname is returned and used for matching.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

skipRouteOnParseError causes incorrect param stringification

2 participants