Skip to content

fix(react-router): re-export PathParamError from framework packages#7612

Open
LeSingh1 wants to merge 1 commit into
TanStack:mainfrom
LeSingh1:fix/export-path-param-error
Open

fix(react-router): re-export PathParamError from framework packages#7612
LeSingh1 wants to merge 1 commit into
TanStack:mainfrom
LeSingh1:fix/export-path-param-error

Conversation

@LeSingh1

@LeSingh1 LeSingh1 commented Jun 12, 2026

Copy link
Copy Markdown

Summary

Closes #7545.

PathParamError is exported from @tanstack/router-core but was absent from the re-export lists in @tanstack/react-router, @tanstack/solid-router, and @tanstack/vue-router. SearchParamError was already re-exported on that same line — PathParamError was simply never added alongside it.

The practical impact: users who want to distinguish path-param validation failures from other errors in an onError handler or errorComponent had to write:

import { PathParamError } from '@tanstack/router-core' // transitive dep, not a public package

After this fix they can write:

import { PathParamError } from '@tanstack/react-router'
// or @tanstack/solid-router / @tanstack/vue-router

Changes

  • packages/react-router/src/index.tsx — add PathParamError to the existing SearchParamError re-export
  • packages/solid-router/src/index.tsx — same
  • packages/vue-router/src/index.tsx — same
  • packages/react-router/tests/router.test.tsx — new test verifying that a params.parse failure surfaces as PathParamError in the route's errorComponent, imported directly from @tanstack/react-router

Test plan

  • pnpm --filter @tanstack/react-router test:unit — all 44 test files pass (913 tests, +1 from baseline)
  • No type errors

Summary by CodeRabbit

  • New Features

    • PathParamError is now exported from React, Solid, and Vue router packages, enabling developers to handle path parameter validation errors more effectively.
  • Tests

    • Added test coverage for path parameter validation error handling.

PathParamError was exported from @tanstack/router-core but missing from
the re-export lists in @tanstack/react-router, @tanstack/solid-router,
and @tanstack/vue-router. Users who needed to detect path-param
validation failures via `error instanceof PathParamError` were forced
to import from the transitive dependency @tanstack/router-core directly.

Adds PathParamError alongside the existing SearchParamError export in
all three framework packages, and adds a test in react-router to verify
that a failing params.parse callback surfaces as a PathParamError
caught by the route's errorComponent.

Fixes TanStack#7545
@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5843d888-3a95-4046-9231-51ed7e5d9c88

📥 Commits

Reviewing files that changed from the base of the PR and between 96eca43 and 6299cdd.

📒 Files selected for processing (4)
  • packages/react-router/src/index.tsx
  • packages/react-router/tests/router.test.tsx
  • packages/solid-router/src/index.tsx
  • packages/vue-router/src/index.tsx

📝 Walkthrough

Walkthrough

This PR exposes PathParamError as a public API export from react-router, solid-router, and vue-router packages, enabling consumers to use instanceof checks to differentiate between path and search param parsing errors. A regression test validates the error wrapping behavior.

Changes

PathParamError public API

Layer / File(s) Summary
React Router PathParamError export
packages/react-router/src/index.tsx
PathParamError is re-exported from @tanstack/router-core alongside SearchParamError in the package entrypoint.
React Router path param error validation test
packages/react-router/tests/router.test.tsx
New test suite validates that route param parsing errors thrown by a custom params.parse function are wrapped and surfaced as PathParamError instances via the route's errorComponent.
Solid and Vue framework PathParamError exports
packages/solid-router/src/index.tsx, packages/vue-router/src/index.tsx
Solid Router and Vue Router entrypoints are updated to re-export PathParamError, ensuring consistent public API across all framework packages.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested labels

package: react-router

Poem

🐰 A hop, skip, and re-export away—
PathParamError now sees the light of day!
No more hunting through transitive chains,
Just check the type, let the error explain.
Three frameworks strong, the API's now clear! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the primary change: re-exporting PathParamError from framework packages to address the inconsistency where SearchParamError was already re-exported.
Linked Issues check ✅ Passed The PR directly addresses issue #7545 by re-exporting PathParamError from framework packages alongside SearchParamError, enabling consumers to use instanceof checks without importing from transitive dependencies.
Out of Scope Changes check ✅ Passed All changes are within scope: re-exporting PathParamError in three framework packages and adding a regression test verifying the error is properly surfaced in errorComponent.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

error.routerCode removed and not a clear replacement for error.routerCode === 'PARSE_PARAMS' or error.routerCode === 'VALIDATE_SEARCH'

1 participant