{"record":{"id":"a66a0d908bd779a9","repo":"symfony/routing","slug":"using-s-is-not-allowed-in-routing-configuration","errorCode":null,"errorMessage":"Using \"%%%s%%\" is not allowed in routing configuration.","messagePattern":"Using \"%%(.+?)%%\" is not allowed in routing configuration\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"DependencyInjection/Router.php","lineNumber":175,"sourceCode":"            foreach ($value as $key => $val) {\n                $value[$key] = $this->resolve($val);\n            }\n\n            return $value;\n        }\n\n        if (!\\is_string($value)) {\n            return $value;\n        }\n\n        $escapedValue = preg_replace_callback('/%%|%([^%\\s]++)%/', function ($match) use ($value) {\n            // skip %%\n            if (!isset($match[1])) {\n                return '%%';\n            }\n\n            if (preg_match('/^env\\((?:\\w++:)*+\\w++\\)$/', $match[1])) {\n                throw new RuntimeException(\\sprintf('Using \"%%%s%%\" is not allowed in routing configuration.', $match[1]));\n            }\n\n            $resolved = ($this->paramFetcher)($match[1]);\n\n            if (\\is_string($resolved) && preg_match('/env_[a-f0-9]{16}_\\w+_[a-f0-9]{32}/Ui', $resolved)) {\n                throw new RuntimeException(\\sprintf('The container parameter \"%s\" resolves to an env var, which is not allowed in routing configuration.', $match[1]));\n            }\n\n            if (\\is_scalar($resolved)) {\n                $this->collectedParameters[$match[1]] = $resolved;\n\n                if (\\is_string($resolved)) {\n                    $resolved = $this->resolve($resolved);\n                }\n\n                if (\\is_scalar($resolved)) {\n                    return false === $resolved ? '0' : (string) $resolved;\n                }","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/symfony/routing/blob/83fa223250b50f4f018c011e101c330e65ac63cc/DependencyInjection/Router.php#L157-L193","documentation":"Routing configuration is compiled and cached, so it must not contain raw %env(...)%% parameter placeholders (env vars are not available at route-compile time in production). The Router's parameter resolver rejects any %env(...)% placeholder found in routing values.","triggerScenarios":"A route definition (path, host, defaults, requirements) contains a placeholder like '%env(APP_SECRET)%' which Router::resolve matches while expanding %...% parameters.","commonSituations":"Copy-pasting container config syntax into routes.yaml; trying to read env vars in route hosts/defaults; framework.version upgrades surfacing legacy env placeholders in route files.","solutions":["Remove the %env(...)% placeholder from the routing configuration.","Move the env-dependent value into a container parameter (parameters.yaml binds env) and reference %parameter_name% instead.","Use a route loader/condition or runtime requirement that evaluates env at request time rather than compile time.","Keep the resolved parameter from itself containing an env placeholder chain to also avoid error [3]."],"exampleFix":"// before (routes.yaml)\nhost: '%env(APP_HOST)%'\n// after\n# config/packages/app.yaml: parameters: app_host: '%env(APP_HOST)%'\nhost: '%app_host%'","handlingStrategy":"validation","validationCode":"if (preg_match('/%env\\(/', $routeValue)) {\n    throw new LogicException('Route configuration must not contain %env(...)% placeholders.');\n}","typeGuard":null,"tryCatchPattern":"try { $url = $generator->generate($name, $params); } catch (RuntimeException $e) { // env placeholder in routing config\n    throw new ConfigException('Fix routing config: '.$e->getMessage());\n}","preventionTips":["Never use %env(...)% in routes.yaml/attributes","Route env-dependent values through a container parameter","Grep routing files for '%env(' in CI"],"tags":["php","symfony-routing","env-vars"],"backgroundTag":"invalid-config-value","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"}