symfony/symfony · error · RuntimeException

The parameter "path" or "route" is required to configure the

Error message

The parameter "path" or "route" is required to configure the redirect action in "%s" routing configuration.

What it means

Thrown by RedirectController::__invoke() when neither path nor route is present in the route defaults for a redirect. RedirectController needs exactly one target — a route name or a path — to know where to send the user; with neither, it cannot build a RedirectResponse.

Source

Thrown at src/Symfony/Bundle/FrameworkBundle/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 698e28026c)

Solutions

  1. Add either `path: /target` or `route: target_route` to the route's defaults.
  2. Double-check indentation/key spelling in YAML (a mis-indented key is silently ignored).
  3. Use `php bin/console debug:router` to inspect the compiled defaults.

Example fix

# before — config/routes.yaml
legacy:
    path: /legacy
    defaults:
        _controller: Symfony\Bundle\FrameworkBundle\Controller\RedirectController
        permanent: true   # no target!
# after
legacy:
    path: /legacy
    defaults:
        _controller: Symfony\Bundle\FrameworkBundle\Controller\RedirectController
        route: home
        permanent: true
Defensive patterns

Strategy: validation

Validate before calling

// Validate redirect route defaults before deploying
$keys = array_intersect_key($defaults, array_flip(['path', 'route']));
if (count($keys) === 0) {
    throw new \InvalidArgumentException('Redirect route must set either path or route.');
}

Prevention

When it happens

Trigger: A route pointed at RedirectController whose defaults omit both the route and path keys (e.g. only set permanent or ignoreAttributes).

Common situations: Incomplete redirect route config; renaming keys and leaving the target unset; relying on a global redirect template that lost its target.

Related errors


AI-assisted analysis of symfony/symfony@698e28026c (2026-08-06). Data as JSON: /api/errors/1d61dead5b9388f9. Report an issue: GitHub.