symfony/routing · error · RuntimeException
The parameter "path" or "route" is required to configure…
Error message
The parameter "path" or "route" is required to configure the redirect action in "%s" routing configuration.
What it means
RedirectController::__invoke() requires at least one of 'path' or 'route' in the route's defaults; if neither is present it throws a RuntimeException naming the route. Without one of these there is no redirect target.
Solutions
- Add the 'route' default with the target route name
- Or add the 'path' default with the target path
- Check the route name in the message and fix its defaults in your routing config
Example fix
// before
defaults: { _controller: 'Symfony\Bundle\FrameworkBundle\Controller\RedirectController' }
// after
defaults: { _controller: 'Symfony\Bundle\FrameworkBundle\Controller\RedirectController', route: 'home' } Defensive patterns
Strategy: validation
Validate before calling
$defaults = $route->getDefaults();
if (!isset($defaults['route']) && !isset($defaults['path'])) {
throw new \InvalidArgumentException('Redirect route needs a path or route default');
} Try / catch
try {
$response = $redirectController->__invoke($request);
} catch (\RuntimeException $e) {
// fall back to a default redirect or log the broken route name
} Prevention
- Always include route or path in RedirectController defaults
- Run bin/console lint:routes / debug:router to catch incomplete definitions
- Template redirect routes should assert the presence of a target key
When it happens
Trigger: A route mapped to RedirectController (e.g. defaults: ['_controller' => RedirectController::class]) that omits both 'path' and 'route' defaults, typically because of a typo or partially-written config.
Common situations: Hand-editing YAML/XML route definitions and forgetting the target; template-generated redirect routes where the defaults array was built incorrectly.
Understand the failure class
Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.
Related errors
- Ambiguous redirection settings, use the "path" or "route"…
- Case must be a "BackedEnum" instance
- " :: " is not a case of " ".
- Route alias " " can not reference itself.
- The router " " cannot be warmed up because it does not…
AI-assisted analysis of symfony/routing@83fa223250 (2026-09-14).
Data as JSON: /api/errors/28c5f881d500db26.
Report an issue: GitHub.
Appendix: source
Thrown at Controller/RedirectController.php:185
}
public function __invoke(Request $request): Response
{
$p = $request->attributes->get('_route_params', []);
if (\array_key_exists('route', $p)) {
if (\array_key_exists('path', $p)) {
throw new \RuntimeException(\sprintf('Ambiguous redirection settings, use the "path" or "route" parameter, not both: "%s" and "%s" found respectively in "%s" routing configuration.', $p['path'], $p['route'], $request->attributes->get('_route')));
}
return $this->redirectAction($request, $p['route'], $p['permanent'] ?? false, $p['ignoreAttributes'] ?? false, $p['keepRequestMethod'] ?? false, $p['keepQueryParams'] ?? false);
}
if (\array_key_exists('path', $p)) {
return $this->urlRedirectAction($request, $p['path'], $p['permanent'] ?? false, $p['scheme'] ?? null, $p['httpPort'] ?? null, $p['httpsPort'] ?? null, $p['keepRequestMethod'] ?? false);
}
throw new \RuntimeException(\sprintf('The parameter "path" or "route" is required to configure the redirect action in "%s" routing configuration.', $request->attributes->get('_route')));
}
}
View on GitHub (pinned to 83fa223250)