{"record":{"id":"d17dd8c8f94b85c2","repo":"symfony/routing","slug":"the-routing-file-s-must-not-specify-other-keys-than-alias","errorCode":null,"errorMessage":"The routing file \"%s\" must not specify other keys than \"alias\" and \"deprecated\" for \"%s\".","messagePattern":"The routing file \"(.+?)\" must not specify other keys than \"alias\" and \"deprecated\" for \"(.+?)\"\\.","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"Loader/ContentLoaderTrait.php","lineNumber":249,"sourceCode":"        if (isset($config['stateless']) && isset($config['defaults']['_stateless'])) {\n            throw new \\InvalidArgumentException(\\sprintf('The routing file \"%s\" must not specify both the \"stateless\" key and the defaults key \"_stateless\" for \"%s\".', $path, $name));\n        }\n        if (isset($config['firewall']) && isset($config['defaults']['_firewall'])) {\n            throw new \\InvalidArgumentException(\\sprintf('The routing file \"%s\" must not specify both the \"firewall\" key and the defaults key \"_firewall\" for \"%s\".', $path, $name));\n        }\n    }\n\n    /**\n     * Validates that an alias definition only carries the `alias` and `deprecated` keys.\n     *\n     * @throws \\InvalidArgumentException If one of the provided config keys is not supported,\n     *                                   something is missing or the combination is nonsense\n     */\n    private function validateAlias(array $config, string $name, string $path): void\n    {\n        foreach ($config as $key => $value) {\n            if (!\\in_array($key, ['alias', 'deprecated'], true)) {\n                throw new \\InvalidArgumentException(\\sprintf('The routing file \"%s\" must not specify other keys than \"alias\" and \"deprecated\" for \"%s\".', $path, $name));\n            }\n\n            if ('deprecated' === $key) {\n                if (!isset($value['package'])) {\n                    throw new \\InvalidArgumentException(\\sprintf('The routing file \"%s\" must specify the attribute \"package\" of the \"deprecated\" option for \"%s\".', $path, $name));\n                }\n\n                if (!isset($value['version'])) {\n                    throw new \\InvalidArgumentException(\\sprintf('The routing file \"%s\" must specify the attribute \"version\" of the \"deprecated\" option for \"%s\".', $path, $name));\n                }\n            }\n        }\n    }\n}\n","sourceCodeStart":231,"sourceCodeEnd":264,"githubUrl":"https://github.com/symfony/routing/blob/83fa223250b50f4f018c011e101c330e65ac63cc/Loader/ContentLoaderTrait.php#L231-L264","documentation":"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.","triggerScenarios":"A routing entry with an 'alias' key that also contains keys like 'path', 'controller', 'defaults' or 'requirements'.","commonSituations":"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'.","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"],"exampleFix":"# before\napp_new:\n    alias: app_old\n    path: /old\n    controller: App\\Controller\\OldController\n\n# after\napp_new:\n    alias: app_old","handlingStrategy":"validation","validationCode":"if (isset($config['alias'])) {\n    $extra = array_diff(array_keys($config), ['alias', 'deprecated']);\n    if ($extra) { throw new \\LogicException(sprintf('Alias may only have alias/deprecated keys, got: %s', implode(',', $extra))); }\n}","typeGuard":"function isPureAlias(array $config): bool { return isset($config['alias']) && empty(array_diff(array_keys($config), ['alias', 'deprecated'])); }","tryCatchPattern":"try { $collection = $loader->load($file, 'yaml'); } catch (\\InvalidArgumentException $e) { /* alias entry has extra keys; strip them */ }","preventionTips":["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"],"tags":["symfony","routing","config-validation","route-alias"],"backgroundTag":"schema-validation-failed","analyzedSha":"83fa223250b50f4f018c011e101c330e65ac63cc","analyzedAt":"2026-09-14T03:19:46.280Z","contentChangedAt":"2026-09-14T03:19:46.280Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}