Skip to content

fix(docs): Prevent unhandled error for invalid library IDs in docs head() - #1207

Open
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/docs-invalid-library-id-error
Open

fix(docs): Prevent unhandled error for invalid library IDs in docs head()#1207
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/docs-invalid-library-id-error

Conversation

@sentry

@sentry sentry Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

This PR addresses an issue where navigating to documentation URLs with invalid library IDs (e.g., /select/latest/...) resulted in an unhandled error during hydration, instead of a graceful 404.

Root Cause:
The head() function in src/routes/_library/$libraryId/$version.docs.framework.$framework.$.tsx was calling getLibrary(libraryId). The getLibrary() utility throws an error if the provided libraryId does not exist. While the parent route (/_library/$libraryId/route.tsx) correctly uses findLibrary() and throws notFound() for invalid IDs, TanStack Router's hydration process still evaluates the child route's head() function, leading to the unhandled error.

Solution:

  1. Updated the imports in src/routes/_library/$libraryId/$version.docs.framework.$framework.$.tsx to include findLibrary and notFound.
  2. Modified the head() function in the same file to use findLibrary(libraryId) instead of getLibrary(libraryId).
  3. Added a conditional check: if findLibrary returns undefined (meaning the library was not found), throw notFound() is called. This aligns the behavior with sibling routes (e.g., src/routes/_library/$libraryId/$version.docs.$.tsx) and ensures that invalid library IDs are handled gracefully, resulting in a proper 404 page.

Fixes TANSTACK-COM-45W

This PR was automatically generated by Sentry. You can adjust this setting at any time.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
tanstack-com e525d95 Commit Preview URL

Branch Preview URL
Aug 31 2026, 11:06 PM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

0 participants