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

  1. Add the 'route' default with the target route name
  2. Or add the 'path' default with the target path
  3. 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

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


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)