{"record":{"id":"0ed7641af16854ef","repo":"symfony/routing","slug":"route-to-s-is-missing-paths-for-locale-s-s","errorCode":null,"errorMessage":"Route to \"%s\" is missing paths for locale(s) \"%s\".","messagePattern":"Route to \"(.+?)\" is missing paths for locale\\(s\\) \"(.+?)\"\\.","errorType":"exception","errorClass":"LogicException","httpStatus":null,"severity":"error","filePath":"Loader/AttributeClassLoader.php","lineNumber":182,"sourceCode":"        $options = array_replace($globals['options'], $attr->options);\n        $schemes = array_unique(array_merge($globals['schemes'], $attr->schemes));\n        $methods = array_unique(array_merge($globals['methods'], $attr->methods));\n\n        $host = $attr->host ?? $globals['host'];\n        $condition = $attr->condition ?? $globals['condition'];\n        $priority = $attr->priority ?? $globals['priority'];\n\n        $path = $attr->path;\n        $prefix = $globals['localized_paths'] ?: $globals['path'];\n        $paths = [];\n\n        if (\\is_array($path)) {\n            if (!\\is_array($prefix)) {\n                foreach ($path as $locale => $localePath) {\n                    $paths[$locale] = $prefix.$localePath;\n                }\n            } elseif ($missing = array_diff_key($prefix, $path)) {\n                throw new \\LogicException(\\sprintf('Route to \"%s\" is missing paths for locale(s) \"%s\".', $class->name.'::'.$method->name, implode('\", \"', array_keys($missing))));\n            } else {\n                foreach ($path as $locale => $localePath) {\n                    if (!isset($prefix[$locale])) {\n                        throw new \\LogicException(\\sprintf('Route to \"%s\" with locale \"%s\" is missing a corresponding prefix in class \"%s\".', $method->name, $locale, $class->name));\n                    }\n\n                    $paths[$locale] = $prefix[$locale].$localePath;\n                }\n            }\n        } elseif (\\is_array($prefix)) {\n            foreach ($prefix as $locale => $localePrefix) {\n                $paths[$locale] = $localePrefix.$path;\n            }\n        } else {\n            $paths[] = $prefix.$path;\n        }\n\n        foreach ($method->getParameters() as $param) {","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/symfony/routing/blob/83fa223250b50f4f018c011e101c330e65ac63cc/Loader/AttributeClassLoader.php#L164-L200","documentation":"When a route method path and the class-level prefix are both locale-keyed arrays, every prefix locale must have a matching path locale. addRoute uses array_diff_key to find prefix locales absent from the path array and throws LogicException listing the missing locales.","triggerScenarios":"Class has #[Route(path: ['en' => '/en', 'nl' => '/nl'])] but the method declares a localized path missing some locales, e.g. path: ['en' => '/blog'] — the 'nl' prefix has no corresponding path.","commonSituations":"Adding a new locale to the class-level prefix without updating every localized action path; partially translated controllers; copy-pasting a localized route and deleting one locale entry.","solutions":["Add a path entry for every locale present in the class-level prefix","Or remove the extra locale from the class-level #[Route] prefix","Or make the method path non-localized (plain string) if localization is only needed at prefix level"],"exampleFix":"// before\n#[Route(path: ['en' => '/en', 'nl' => '/nl'])]\nclass BlogController {\n  #[Route(path: ['en' => '/blog'])]\n  public function index() {}\n}\n// after\n#[Route(path: ['en' => '/blog', 'nl' => '/blog'])]\n  public function index() {}","handlingStrategy":"validation","validationCode":"$missing = array_diff_key(array_keys($classPrefix), array_keys($methodPath)); if ($missing) { /* fix before loading */ }","typeGuard":"function localesMatch(array $prefix, array $path): bool { return !array_diff_key($prefix, $path); }","tryCatchPattern":"try { $routes = $loader->load($file); } catch (\\LogicException $e) { /* missing locale path/prefix — fix route attributes */ }","preventionTips":["Keep class prefix and method path locale arrays identical","Define the supported locale list once as a constant and build both arrays from it","Add a smoke test that loads all route files in CI"],"tags":["routing","i18n","localized-routes"],"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"}