{"record":{"id":"bb662d7bc77ef3fd","repo":"symfony/routing","slug":"the-container-parameter-s-used-in-the-route-configuration","errorCode":null,"errorMessage":"The container parameter \"%s\", used in the route configuration value \"%s\", must be a string or numeric, but it is of type \"%s\".","messagePattern":"The container parameter \"(.+?)\", used in the route configuration value \"(.+?)\", must be a string or numeric, but it is of type \"(.+?)\"\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"DependencyInjection/Router.php","lineNumber":196,"sourceCode":"            $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                }\n            }\n\n            throw new RuntimeException(\\sprintf('The container parameter \"%s\", used in the route configuration value \"%s\", must be a string or numeric, but it is of type \"%s\".', $match[1], $value, get_debug_type($resolved)));\n        }, $value);\n\n        return str_replace('%%', '%', $escapedValue);\n    }\n\n    public static function getSubscribedServices(): array\n    {\n        return [\n            'routing.loader' => LoaderInterface::class,\n        ];\n    }\n}\n","sourceCodeStart":178,"sourceCodeEnd":209,"githubUrl":"https://github.com/symfony/routing/blob/83fa223250b50f4f018c011e101c330e65ac63cc/DependencyInjection/Router.php#L178-L209","documentation":"Route configuration values are built from container parameters; every matched %param% must resolve to a string or scalar so it can be cast. This error means the parameter resolved to a non-scalar type (array, null, object) and cannot be embedded in the route configuration string.","triggerScenarios":"Router::resolve finds %param% in a route value, paramFetcher returns an array/null/resource, and get_debug_type reports a non-scalar type.","commonSituations":"Defining a route default or host as an array parameter in config; a YAML parameter parsed as a list; a null parameter after failed env resolution.","solutions":["Change the parameter to a scalar (string/int/bool) value in your config.","Reference a specific scalar element of the array parameter instead of the whole array.","Check config parsing: YAML values like 'key: [a, b]' become arrays; quote or restructure them."],"exampleFix":"// before (config.yaml)\nparameters:\n  app_hosts: ['a.com', 'b.com']\n# routes.yaml: host: '%app_hosts%'\n// after\nparameters:\n  app_host: 'a.com'\n# routes.yaml: host: '%app_host%'","handlingStrategy":"type-guard","validationCode":"$v = $container->getParameter($name);\nif (!is_scalar($v) && null !== $v) {\n    throw new LogicException(\"Parameter $name must be scalar for routing use.\");\n}","typeGuard":"function isScalarParam(mixed $v): bool { return is_scalar($v) || null === $v; }","tryCatchPattern":"try { $url = $generator->generate($name, $params); } catch (RuntimeException $e) { // non-scalar parameter in route config\n    $logger->error($e->getMessage());\n}","preventionTips":["Keep routing-referenced parameters scalar","Check YAML types (lists/quotes) for parameters used in routes","Cast explicitly when defining parameters programmatically"],"tags":["php","symfony-routing","type-mismatch"],"backgroundTag":"type-mismatch","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"}