[Bug][Core] `getPageBySlugs` can't find pages whose slugs need encoding when the router passes decoded params (TanStack Start)
To Reproduce
In the
tanstack-start-openapiexample, use an operation whoseoperationIdcontains a space (with the defaultv2naming, the page file is named after theoperationId):paths: /things/{id}: get: tags: [Things] operationId: Get A Thing responses: '200': { description: OK }A docs page file with a space or non-ASCII characters in its name hits the same path.
Open the page from the sidebar.
Current vs. Expected behavior
Current: 404. With prerendering enabled, the build fails with Failed to fetch /docs/things/Get A Thing: Not Found.
Expected: The page resolves.
Framework
Tanstack Start
Provide environment information
Framework: TanStack Start 1.168.50 (@tanstack/react-router 1.170.33), Vite 8.2.2
Operating System:
Platform: win32
Binaries:
Node: 24.12.0
Relevant Packages:
fumadocs-core: 16.15.15
fumadocs-ui: 16.15.15
fumadocs-mdx: 15.4.0
fumadocs-openapi: 11.4.1
react: 19.2.8
react-dom: 19.2.8Which area(s) are affected? (Select all that apply)
Core, Examples
Additional context
Observed on the versions above. The same code is in fumadocs-openapi 12.0.4 and on dev as of 1bc5374; source paths are relative to packages/ on that commit.
- The slugs plugin stores each segment with
encodeURI(core/src/source/plugins/slugs.ts:115and:121), so the page's slug isGet%20A%20Thing. - TanStack Router hands
params._splatback decoded:@tanstack/router-corerunsdecodeURIComponenton it when matching. The example route passes it straight through:params._splat?.split('/')→source.getPage(slugs). source.getPagecallsgetPageBySlugs(core/src/source/loader.ts:236–242,:430). That tries the slugs as given, thenslugs.map(decodeURI). Both are the decoded form, so neither matches the stored, encoded key.
The same params._splat?.split('/') pattern is in every TanStack Start example (tanstack-start, -min, -openapi, -spa, -local-md, -story, -i18n), including the {$}[.]md.ts routes. Next.js passes params still encoded, which is probably why this hasn't come up there.
A possible fix is to normalize in getPageBySlugs, for example by also trying slugs.map((s) => encodeURI(decodeURI(s))). The alternative is to have the TanStack examples/templates encode each segment before getPage. We work around it that way today, with .map(encodeURI) on the splat segments.
Source: fuma-nama/fumadocs