Skip to content

Conversation

ematipico
Copy link
Member

Changes

Closes #12036

Astro didn't perform any validation of the route mappings. This PR introduces a new function that performs this task.

An error is thrown when a redirect can't be mapped to a new route.

Testing

Added a new test

Docs

Copy link

changeset-bot bot commented Jul 30, 2025

🦋 Changeset detected

Latest commit: 9bdc5ad

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added pkg: astro Related to the core `astro` package (scope) docs pr labels Jul 30, 2025
Copy link

codspeed-hq bot commented Jul 30, 2025

CodSpeed Performance Report

Merging #14161 will not alter performance

Comparing fix/routing-validation (92632a6) with main (34e6b3a)1

Summary

✅ 6 untouched benchmarks

Footnotes

  1. No successful run was found on main (c86b5bb) during the generation of this report, so 34e6b3a was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@ematipico ematipico force-pushed the fix/routing-validation branch from df7778d to 942a721 Compare July 30, 2025 10:49
@ematipico ematipico force-pushed the fix/routing-validation branch from 942a721 to 37e57c5 Compare July 30, 2025 11:01
Copy link
Contributor

@ascorbic ascorbic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would be the behaviour now, if one of these invalid redirects was created?

@ematipico
Copy link
Member Author

What would be the behaviour now, if one of these invalid redirects was created?

As mentioned in the bug report, the error is generic:

[ERROR] [build] Failed to call getStaticPaths for /categories/[category]
[GetStaticPathsRequired] `getStaticPaths()` function is required for dynamic routes. Make sure that you `export` a `getStaticPaths` function from your dynamic route.

@ematipico ematipico requested a review from ascorbic July 31, 2025 11:26
@ematipico ematipico requested a review from ascorbic July 31, 2025 13:19
@ascorbic
Copy link
Contributor

This still doesn't test for the example in the issue, and I'm not sure it would catch it. The original had the same number of dynamic segments on each side:

redirects: {
  '/categories/[category]': '/category/[category]/1',
}

@ematipico
Copy link
Member Author

Sorry, I missed that. I'll add a test for that too

@florian-lefebvre
Copy link
Member

@ematipico what are your plans for this PR?

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

Labels

docs pr pkg: astro Related to the core `astro` package (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Misleading missing getStaticPaths error with configured redirects and dynamic routes

3 participants