symfony/routing · error · InvalidArgumentException
The routing file " " must not specify other keys than…
Error message
The routing file "%s" must not specify other keys than "alias" and "deprecated" for "%s".
What it means
When a routing entry defines an 'alias', the whole entry may only contain the 'alias' and 'deprecated' keys — aliases are pure redirects to another route name and carry no path, controller, etc. ContentLoaderTrait::validateAlias() throws InvalidArgumentException for any other key found in the entry.
Solutions
- Delete every key except 'alias' (and optionally 'deprecated') from the entry
- If the entry needs path/controller, it is not an alias — remove the 'alias' key and define a normal route
- Create a separate entry if you need both the original route and an alias
Example fix
# before
app_new:
alias: app_old
path: /old
controller: App\Controller\OldController
# after
app_new:
alias: app_old Defensive patterns
Strategy: validation
Validate before calling
if (isset($config['alias'])) {
$extra = array_diff(array_keys($config), ['alias', 'deprecated']);
if ($extra) { throw new \LogicException(sprintf('Alias may only have alias/deprecated keys, got: %s', implode(',', $extra))); }
} Type guard
function isPureAlias(array $config): bool { return isset($config['alias']) && empty(array_diff(array_keys($config), ['alias', 'deprecated'])); } Try / catch
try { $collection = $loader->load($file, 'yaml'); } catch (\InvalidArgumentException $e) { /* alias entry has extra keys; strip them */ } Prevention
- Aliases must contain only 'alias' and optionally 'deprecated'
- When converting a route to an alias, delete path/controller/defaults
- Define original route and alias as separate entries
When it happens
Trigger: A routing entry with an 'alias' key that also contains keys like 'path', 'controller', 'defaults' or 'requirements'.
Common situations: Converting an existing route into an alias (e.g. for a rename/deprecation) without deleting its old keys; copy-pasting a full route block and swapping 'path' for 'alias'.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- The definition of " " in " " must be an array.
- The routing file " " contains unsupported keys for " ": "…
- The routing file " " must not specify both the "resource"…
- The "type" key for the route definition
- You must define a "path" for the route
AI-assisted analysis of symfony/routing@83fa223250 (2026-09-14).
Data as JSON: /api/errors/d17dd8c8f94b85c2.
Report an issue: GitHub.
Appendix: source
Thrown at Loader/ContentLoaderTrait.php:249
if (isset($config['stateless']) && isset($config['defaults']['_stateless'])) {
throw new \InvalidArgumentException(\sprintf('The routing file "%s" must not specify both the "stateless" key and the defaults key "_stateless" for "%s".', $path, $name));
}
if (isset($config['firewall']) && isset($config['defaults']['_firewall'])) {
throw new \InvalidArgumentException(\sprintf('The routing file "%s" must not specify both the "firewall" key and the defaults key "_firewall" for "%s".', $path, $name));
}
}
/**
* Validates that an alias definition only carries the `alias` and `deprecated` keys.
*
* @throws \InvalidArgumentException If one of the provided config keys is not supported,
* something is missing or the combination is nonsense
*/
private function validateAlias(array $config, string $name, string $path): void
{
foreach ($config as $key => $value) {
if (!\in_array($key, ['alias', 'deprecated'], true)) {
throw new \InvalidArgumentException(\sprintf('The routing file "%s" must not specify other keys than "alias" and "deprecated" for "%s".', $path, $name));
}
if ('deprecated' === $key) {
if (!isset($value['package'])) {
throw new \InvalidArgumentException(\sprintf('The routing file "%s" must specify the attribute "package" of the "deprecated" option for "%s".', $path, $name));
}
if (!isset($value['version'])) {
throw new \InvalidArgumentException(\sprintf('The routing file "%s" must specify the attribute "version" of the "deprecated" option for "%s".', $path, $name));
}
}
}
}
}
View on GitHub (pinned to 83fa223250)