{"record":{"id":"62836c9d89287e16","repo":"symfony/routing","slug":"a-placeholder-name-must-be-a-string-d-given-did-you-forget-62836c","errorCode":null,"errorMessage":"A placeholder name must be a string (%d given). Did you forget to specify the placeholder key for the requirement \"%s\" of route \"%s\" in \"%s\"?","messagePattern":"A placeholder name must be a string \\((.+?) given\\)\\. Did you forget to specify the placeholder key for the requirement \"(.+?)\" of route \"(.+?)\" in \"(.+?)\"\\?","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"Loader/ContentLoaderTrait.php","lineNumber":87,"sourceCode":"            $deprecation = $config['deprecated'] ?? null;\n            if (null !== $deprecation) {\n                $alias->setDeprecated(\n                    $deprecation['package'],\n                    $deprecation['version'],\n                    $deprecation['message'] ?? ''\n                );\n            }\n\n            return;\n        }\n\n        $defaults = $config['defaults'] ?? [];\n        $requirements = $config['requirements'] ?? [];\n        $options = $config['options'] ?? [];\n\n        foreach ($requirements as $placeholder => $requirement) {\n            if (\\is_int($placeholder)) {\n                throw new \\InvalidArgumentException(\\sprintf('A placeholder name must be a string (%d given). Did you forget to specify the placeholder key for the requirement \"%s\" of route \"%s\" in \"%s\"?', $placeholder, $requirement, $name, $path));\n            }\n        }\n\n        if (isset($config['controller'])) {\n            $defaults['_controller'] = $config['controller'];\n        }\n        if (isset($config['locale'])) {\n            $defaults['_locale'] = $config['locale'];\n        }\n        if (isset($config['format'])) {\n            $defaults['_format'] = $config['format'];\n        }\n        if (isset($config['utf8'])) {\n            $options['utf8'] = $config['utf8'];\n        }\n        if (isset($config['stateless'])) {\n            $defaults['_stateless'] = $config['stateless'];\n        }","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/symfony/routing/blob/83fa223250b50f4f018c011e101c330e65ac63cc/Loader/ContentLoaderTrait.php#L69-L105","documentation":"In parseRoute(), requirements must be keyed by placeholder name (string). A numeric key means a requirement was written as a bare list item without its placeholder key, e.g. \"requirements: ['\\\\d+']\" instead of \"requirements: [id: '\\\\d+']\". The loader throws an InvalidArgumentException telling you which requirement and route to fix.","triggerScenarios":"YAML/PHP config where requirements uses numeric keys: `requirements: - '\\d+'` or `[0 => '\\d+']` in PHP arrays built programmatically (e.g. array_values() destroying keys).","commonSituations":"Hand-written YAML lists instead of maps; PHP config generated with array_push/array_values that drops string keys; copy-paste from docs losing indentation turning a map into a sequence.","solutions":["Give each requirement its placeholder key: requirements: { id: '\\d+' }.","In YAML, use `requirements:` with `id: '\\d+'` (map) rather than a dash-list.","If building config in PHP, preserve keys — avoid array_values()/array_merge of such maps."],"exampleFix":"// before\n['requirements' => ['\\d+']]\n// after\n['requirements' => ['id' => '\\d+']]","handlingStrategy":"validation","validationCode":"foreach ($requirements as $k => $v) { if (\\is_int($k)) { throw new \\InvalidArgumentException(\"Requirement for placeholder missing (got {$v})\"); } }","typeGuard":null,"tryCatchPattern":"try { $loader->load($file); } catch (\\InvalidArgumentException $e) { /* fix the named requirement to use placeholder keys */ }","preventionTips":["Always write requirements as maps: { placeholder: regex }.","Avoid array_values/array_push on requirement maps.","Lint YAML for dash-lists under 'requirements:'."],"tags":["routing","yaml-config","requirements","symfony"],"backgroundTag":"invalid-argument-format","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"}