facebook/docusaurus · error · Error
Some created redirects are invalid: - ${redirectValidationEr
Error message
Some created redirects are invalid:
- ${redirectValidationErrors.join('\n- ')}
What it means
Thrown by validateCollectedRedirects() in @docusaurus/plugin-client-redirects when at least one collected redirect fails validateRedirect() (e.g. malformed from/to). All collected redirects are validated and their error messages aggregated, so the thrown message lists every offending redirect at once.
Source
Thrown at packages/docusaurus-plugin-client-redirects/src/collectRedirects.ts:84
return filterUnwantedRedirects(redirects, pluginContext);
}
function validateCollectedRedirects(
redirects: RedirectItem[],
pluginContext: PluginContext,
) {
const redirectValidationErrors = redirects
.map((redirect) => {
try {
validateRedirect(redirect);
return undefined;
} catch (err) {
return (err as Error).message;
}
})
.filter(Boolean);
if (redirectValidationErrors.length > 0) {
throw new Error(
`Some created redirects are invalid:
- ${redirectValidationErrors.join('\n- ')}
`,
);
}
const allowedToPaths = pluginContext.relativeRoutesPaths.map((p) =>
decodeURI(p),
);
const toPaths = redirects
.map((redirect) => redirect.to)
// We now allow "to" to contain any string
// We only do this "broken redirect" check from to that looks like pathnames
// note: we allow querystring/anchors
// See https://github.com/facebook/docusaurus/issues/6845
.map((to) => {
if (to.startsWith('/')) {
const url = URL.parse(to, 'https://example.com');View on GitHub (pinned to 3f483e80e3)
Solutions
- Read the bulleted list in the error: each line is one validateRedirect failure message naming the bad redirect.
- Fix each listed redirect's from/to to be valid absolute internal paths (leading slash).
- If using createRedirects, ensure it only returns strings starting with '/' (or [] / '' for none).
- Re-run the build to confirm no further validation errors.
Example fix
// before createRedirects: (path) => 'old' + path, // no leading slash // after createRedirects: (path) => '/old' + path,
Defensive patterns
Strategy: validation
Validate before calling
function isValidRedirectPath(p: string): boolean {
return typeof p === 'string' && p.startsWith('/') && p.length > 1;
}
// validate createRedirects output before returning it:
const froms = (createRedirects?.(path) ?? []);
const arr = Array.isArray(froms) ? froms : [froms];
arr.forEach((f) => { if (!isValidRedirectPath(f)) throw new Error(`Bad redirect from: ${f}`); }); Type guard
const isRedirectItem = (r: unknown): r is {from: string; to: string} =>
!!r && typeof (r as any).from === 'string' && typeof (r as any).to === 'string'
&& (r as any).from.startsWith('/') && (r as any).to.startsWith('/'); Prevention
- Always return absolute internal paths (leading slash) from createRedirects.
- Return [] or '' instead of invalid strings when no redirect applies.
- Add a unit test for your createRedirects function covering edge-case inputs.
When it happens
Trigger: Configuring fromExtensions/toExtensions/redirects/createRedirects in a way that produces a RedirectItem with a from or to that fails validateRedirect (e.g. relative path not starting with '/', empty string, external URL in a field that expects an internal path). Reached during build when collectRedirects runs.
Common situations: A createRedirects callback returning a path without a leading slash; an extensions config producing an empty from; a redirects option with from:'' or to:''; trailing-slash mismatches that produce an invalid combination.
Related errors
- You are trying to create client-side redirections to invalid
- Extension "${ext}" is not allowed. If the redirect extension
- Extension "${ext}" contains a "." (dot) which is not allowed
- Extension "${ext}" contains a "/" (slash) which is not allow
- Extension "${ext}" contains invalid URI characters. If the r
AI-assisted analysis of facebook/docusaurus@3f483e80e3 (2026-08-12).
Data as JSON: /api/errors/a4b996c5411a1526.
Report an issue: GitHub.