{"record":{"id":"e7d67bdff91df99d","repo":"symfony/routing","slug":"route-s-with-locale-s-is-missing-a-corresponding-prefix-in-e7d67b","errorCode":null,"errorMessage":"Route \"%s\" with locale \"%s\" is missing a corresponding prefix in its parent collection.","messagePattern":"Route \"(.+?)\" with locale \"(.+?)\" is missing a corresponding prefix in its parent collection\\.","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"Loader/Configurator/Traits/PrefixTrait.php","lineNumber":53,"sourceCode":"                if (null === $locale = $route->getDefault('_locale')) {\n                    $priority = $routes->getPriority($name) ?? 0;\n                    $routes->remove($name);\n                    foreach ($aliases[$name] ?? [] as $aliasName) {\n                        $routes->remove($aliasName);\n                    }\n                    foreach ($prefix as $locale => $localePrefix) {\n                        $localizedRoute = clone $route;\n                        $localizedRoute->setDefault('_locale', $locale);\n                        $localizedRoute->setRequirement('_locale', preg_quote($locale));\n                        $localizedRoute->setDefault('_canonical_route', $name);\n                        $localizedRoute->setPath($localePrefix.(!$trailingSlashOnRoot && '/' === $route->getPath() ? '' : $route->getPath()));\n                        $routes->add($name.'.'.$locale, $localizedRoute, $priority);\n                        foreach ($aliases[$name] ?? [] as $aliasName) {\n                            $routes->addAlias($aliasName.'.'.$locale, $name.'.'.$locale);\n                        }\n                    }\n                } elseif (!isset($prefix[$locale])) {\n                    throw new \\InvalidArgumentException(\\sprintf('Route \"%s\" with locale \"%s\" is missing a corresponding prefix in its parent collection.', $name, $locale));\n                } else {\n                    $route->setPath($prefix[$locale].(!$trailingSlashOnRoot && '/' === $route->getPath() ? '' : $route->getPath()));\n                    $routes->add($name, $route, $routes->getPriority($name) ?? 0);\n                }\n            }\n\n            return;\n        }\n\n        $routes->addPrefix($prefix);\n        if (!$trailingSlashOnRoot) {\n            $rootPath = (new Route(trim(trim($prefix), '/').'/'))->getPath();\n            foreach ($routes->all() as $route) {\n                if ($route->getPath() === $rootPath) {\n                    $route->setPath(rtrim($rootPath, '/'));\n                }\n            }\n        }","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/symfony/routing/blob/83fa223250b50f4f018c011e101c330e65ac63cc/Loader/Configurator/Traits/PrefixTrait.php#L35-L71","documentation":"PrefixTrait::addPrefix() walks a route's localized paths and applies the parent collection's prefix per locale. When a route declares a locale that has no prefix in the parent's prefix array, it throws an InvalidArgumentException — same family as error 44 but at the import/collection level (parseImport path).","triggerScenarios":"Importing a collection whose routes use localized paths for locales not present in the parent ->prefix([...]) map; key mismatches between route locale keys and the prefix array.","commonSituations":"Config file imports where child route files were updated to a new locale but the parent's prefix() call wasn't; locale subtag mismatches ('de-AT' vs 'de').","solutions":["Add the missing locale to the parent collection's prefix map.","Correct locale key typos in the route or import configuration.","Remove unsupported locales from the imported route definitions."],"exampleFix":"// before\n$collection->prefix(['en' => '/en'])->import('routes/');\n// routes/ contains 'de' paths\n// after\n$collection->prefix(['en' => '/en', 'de' => '/de'])->import('routes/');","handlingStrategy":"validation","validationCode":"foreach ($routeLocales as $locale) { if (!isset($parentPrefix[$locale])) { throw new \\InvalidArgumentException(\"No prefix for {$locale}\"); } }","typeGuard":null,"tryCatchPattern":"try { $collection->prefix($prefix)->import($resource); } catch (\\InvalidArgumentException $e) { /* fix prefix/locale mismatch in config */ }","preventionTips":["Define prefixes once from the master locale list.","Synchronize child route locales with the importing collection's prefix().","Add config linting that cross-checks locale keys."],"tags":["routing","i18n","prefix","symfony"],"backgroundTag":"missing-required-config-field","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"}