{"record":{"id":"ff071330f47bae6f","repo":"symfony/routing","slug":"the-router-does-not-support-the-s-option","errorCode":null,"errorMessage":"The Router does not support the \"%s\" option.","messagePattern":"The Router does not support the \"(.+?)\" option\\.","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"Router.php","lineNumber":120,"sourceCode":"            } else {\n                $invalid[] = $key;\n            }\n        }\n\n        if ($invalid) {\n            throw new \\InvalidArgumentException(\\sprintf('The Router does not support the following options: \"%s\".', implode('\", \"', $invalid)));\n        }\n    }\n\n    /**\n     * Sets an option.\n     *\n     * @throws \\InvalidArgumentException\n     */\n    public function setOption(string $key, mixed $value): void\n    {\n        if (!\\array_key_exists($key, $this->options)) {\n            throw new \\InvalidArgumentException(\\sprintf('The Router does not support the \"%s\" option.', $key));\n        }\n\n        $this->options[$key] = $value;\n    }\n\n    /**\n     * Gets an option value.\n     *\n     * @throws \\InvalidArgumentException\n     */\n    public function getOption(string $key): mixed\n    {\n        if (!\\array_key_exists($key, $this->options)) {\n            throw new \\InvalidArgumentException(\\sprintf('The Router does not support the \"%s\" option.', $key));\n        }\n\n        return $this->options[$key];\n    }","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/symfony/routing/blob/83fa223250b50f4f018c011e101c330e65ac63cc/Router.php#L102-L138","documentation":"Symfony's Router only supports a fixed set of options (cache_dir, debug, generator_class, generator_dumper_class, matcher_class, matcher_dumper_class, resource_type, strict_requirements). Router::setOption() checks the key against $this->options (initialized in setOptions()) and throws InvalidArgumentException for any unknown key, failing fast on typos or removed options.","triggerScenarios":"Calling $router->setOption('some_key', $value) with a key that is not one of the 8 supported option names, e.g. a typo like 'cache_dir ' (trailing space), 'cachedir', 'cacheDir' (wrong case), or an option from a different component.","commonSituations":"Typo or wrong casing in an option name; copying options from an older/newer Symfony version where an option was renamed or removed; passing framework-bundle config keys (e.g. 'utf8', 'matcher.cache_dir' from YAML config) directly to the Router class.","solutions":["Check the key against the supported list in Router::setOptions() docblock (Router.php:70-81): cache_dir, debug, generator_class, generator_dumper_class, matcher_class, matcher_dumper_class, resource_type, strict_requirements.","Fix typos and casing — keys are case-sensitive snake_case (e.g. 'cacheDir' → 'cache_dir').","If the option came from an older Symfony version, look up its current replacement in the docs (e.g. matcher_class customization moved to services in newer versions) and pass it where the new version expects it.","If passing many options, use the constructor $options array or setOptions() instead, which reports all invalid keys at once.","Wrap in a check before calling: array via getOption on a known key or compare against a whitelist constant."],"exampleFix":"// before\n$router->setOption('cacheDir', '/var/cache/router');\n// InvalidArgumentException: The Router does not support the \"cacheDir\" option.\n\n// after\n$router->setOption('cache_dir', '/var/cache/router');","handlingStrategy":"validation","validationCode":"const ROUTER_OPTIONS = ['cache_dir','debug','generator_class','generator_dumper_class','matcher_class','matcher_dumper_class','resource_type','strict_requirements'];\nif (!in_array($key, ROUTER_OPTIONS, true)) {\n    throw new LogicException(sprintf('Unknown Router option \"%s\"; supported: %s', $key, implode(', ', ROUTER_OPTIONS)));\n}\n$router->setOption($key, $value);","typeGuard":"function isValidRouterOption(string $key): bool\n{\n    return in_array($key, ['cache_dir','debug','generator_class','generator_dumper_class','matcher_class','matcher_dumper_class','resource_type','strict_requirements'], true);\n}","tryCatchPattern":"try {\n    $router->setOption($key, $value);\n} catch (\\InvalidArgumentException $e) {\n    $this->logger->error('Invalid router option', ['key' => $key, 'message' => $e->getMessage()]);\n    throw new \\LogicException($e->getMessage(), 0, $e);\n}","preventionTips":["Keep the option keys in a shared whitelist constant used by both your config loader and Router calls.","Prefer passing options through the constructor/setOptions() array so all invalid keys are reported in one exception.","Copy option names from the Router::setOptions() docblock or IDE autocompletion, never from memory.","Pin and review Symfony version changes when upgrading — option names can be renamed or removed."],"tags":["symfony","routing","configuration","invalid-option","argument-error"],"backgroundTag":"unsupported-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"}