Skip to content

fix(core): open the first collection when its name has special characters - #8102

Open
martinjagodic wants to merge 1 commit into
mainfrom
fix/default-path-special-chars
Open

martinjagodic wants to merge 1 commit into
mainfrom
fix/default-path-special-chars

Conversation

@martinjagodic

Copy link
Copy Markdown
Member

Fixes #7337.

When the first visible collection's name contains a character that has a meaning in a route pattern, such as (, ), *, +, ? or :, the CMS crashes right after login with TypeError: Expected "0" to be defined. The reporter's collection is named Doc (VI).

React Router 5's Switch passes its match to a Redirect child, and Redirect then runs to through generatePath, which compiles it as a path pattern. (VI) reads as an unnamed parameter 0 that has no value. The default redirects from /, /search/ and the Identity access-denied path were Redirect children of the Switch with to={defaultPath}.

They now render a Redirect inside a Route. That Redirect gets no match, so to is used as is. The redirects inside RouteInCollection were already rendered this way.

Test plan

  • On the dev server with the first collection in dev-test/config.yml renamed to Doc (VI), in headless Chrome:
    • Before: login stays on #/ and the console shows Expected "0" to be defined from generatePath.
    • After: login, #/ and #/search/ all land on #/collections/Doc (VI) and the collection renders.
  • A throwaway spec with MemoryRouter and the same Switch confirmed the old pattern throws and the new one redirects from both / and /search/. It isn't committed, because it only tests React Router.

…ters

A Switch passes its match to a Redirect, which then compiles `to` as a
path pattern. A first collection named `Doc (VI)` made the default
redirect throw 'Expected "0" to be defined' right after login. The
default redirects now render inside a Route.

Fixes #7337
@martinjagodic
martinjagodic requested a review from a team as a code owner November 25, 2026 10:36
@netlify

netlify Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for decap-cms ready!

Name Link
🔨 Latest commit ed8d323
🔍 Latest deploy log https://app.netlify.com/projects/decap-cms/deploys/6b06ba1cd9ffcb0a0c334edf
😎 Deploy Preview https://deploy-preview-8102--decap-cms.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions Bot added the type: bug code to address defects in shipped code label Nov 25, 2026

This branch has not been deployed

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

Labels

type: bug code to address defects in shipped code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeError: Expected "0" to be defined

1 participant