You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
When astro.config.mjs defines a redirect from a dynamic origin to a fully static destination — e.g. '/project/[slug]': '/' — astro build fails with:
[GetStaticPathsRequired] `getStaticPaths()` function is required for dynamic routes.
Make sure that you `export` a `getStaticPaths` function from your dynamic route.
Location:
src/pages/index.astro:0:0
The error is reported against src/pages/index.astro — a static page that has no business being a dynamic route at all. There is no indication that the actual cause is a redirect entry in astro.config.mjs. (When the same configuration is built with @astrojs/cloudflare, the error is reported against the dynamic page being legitimately defined elsewhere in the project — also misleading.)
This appears to be a gap left by #15423 / #12036. That fix added an InvalidRedirectDestination error for the case where a dynamic destination doesn't match any existing route. In this case, the destination /does match a route (the index page), so the new validation passes — but the build still ends up in validateDynamicRouteModule() and throws the misleading GetStaticPathsRequired.
The mismatch here is param count, not destination existence:
When this is combined with @astrojs/cloudflare (#15860), the workerd-side error body is also swallowed by the prerenderer and surfaced as a generic 500: Internal Server Error, which compounds the debugging time significantly.
What's the expected result?
Either:
Preferred — At config validation time, detect that the redirect's destination has fewer (or different) dynamic params than the origin and throw a clear, redirect-specific error pointing at the offending entry in the redirects config. This is a natural extension of the validation fix(routing): improve error for invalid dynamic redirect destinations #15423 added in createRedirectRoutes().
At minimum — When GetStaticPathsRequired is thrown for a route that was reached via a redirect, include the offending redirect rule (e.g. /project/[slug] → /) in the error message and hint, so users can identify it without having to bisect their config.
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
When
astro.config.mjsdefines a redirect from a dynamic origin to a fully static destination — e.g.'/project/[slug]': '/'—astro buildfails with:The error is reported against src/pages/index.astro — a static page that has no business being a dynamic route at all. There is no indication that the actual cause is a redirect entry in astro.config.mjs. (When the same configuration is built with @astrojs/cloudflare, the error is reported against the dynamic page being legitimately defined elsewhere in the project — also misleading.)
This appears to be a gap left by #15423 / #12036. That fix added an
InvalidRedirectDestinationerror for the case where a dynamic destination doesn't match any existing route. In this case, the destination/does match a route (the index page), so the new validation passes — but the build still ends up invalidateDynamicRouteModule()and throws the misleadingGetStaticPathsRequired.The mismatch here is param count, not destination existence:
/categories/[category]/project/[slug]/categories/[category]/1(no matching route)/(matches index)InvalidRedirectDestinationfires?GetStaticPathsRequiredWhen this is combined with
@astrojs/cloudflare(#15860), the workerd-side error body is also swallowed by the prerenderer and surfaced as a generic500: Internal Server Error, which compounds the debugging time significantly.What's the expected result?
Either:
Preferred — At config validation time, detect that the redirect's destination has fewer (or different) dynamic params than the origin and throw a clear, redirect-specific error pointing at the offending entry in the
redirectsconfig. This is a natural extension of the validation fix(routing): improve error for invalid dynamic redirect destinations #15423 added increateRedirectRoutes().At minimum — When
GetStaticPathsRequiredis thrown for a route that was reached via a redirect, include the offending redirect rule (e.g./project/[slug]→/) in the error message and hint, so users can identify it without having to bisect their config.Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-gb9tx9bk?file=src%2Fpages%2F%5Bslug%5D.astro
Participation