Route not found error when creating new search pages

Created on 21 April 2025, about 6 hours ago

Problem/Motivation

When creating a new search page in Drupal's search module (/admin/config/search/pages), users encounter an error immediately after saving the form. This occurs because there's a race condition between saving the search page configuration and rebuilding the routes. The error manifests as "Route 'search.view_[machine_name]' does not exist" and requires a page refresh to resolve.

Steps to reproduce

Go to /admin/config/search/pages
Click "Add search page"
Select any search type (e.g., "Content")
Fill in the form and save
Observe the error: "Route 'search.view_[machine_name]' does not exist"
Refresh the page to see it working correctly

Proposed resolution

Modify the SearchPageAddForm to rebuild routes immediately after saving the search page configuration. This ensures the routes are available in the same request where the search page is created.

Remaining tasks

Add tests to verify the fix
Review and apply patch
Update documentation if necessary

User interface changes

None.

Introduced terminology

None.

API changes

Minor change to SearchPageAddForm to add router.builder service dependency.

Data model changes

None.

Release notes snippet

Fixed a bug where creating new search pages would show a route not found error until the page was refreshed.

🐛 Bug report
Status

Active

Version

11.0 🔥

Component

search.module

Created by

🇧🇪Belgium baikho Antwerp, BE

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024