symfony/symfony · error · InvalidArgumentException

The options tags, tag, parameters & parameter cannot be comb

Error message

The options tags, tag, parameters & parameter cannot be combined together.

What it means

Thrown by `ContainerDebugCommand::validateInput()` when more than one of the listing options (`--tags`, `--tag`, `--parameters`, `--parameter`) is supplied simultaneously without a service name argument. The command can only describe one category of container data at a time, so combining them is rejected up front.

Source

Thrown at src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php:270

     *
     * @throws \InvalidArgumentException
     */
    protected function validateInput(InputInterface $input): void
    {
        $options = ['tags', 'tag', 'parameters', 'parameter'];

        $optionsCount = 0;
        foreach ($options as $option) {
            if ($input->getOption($option)) {
                ++$optionsCount;
            }
        }

        $name = $input->getArgument('name');
        if ((null !== $name) && ($optionsCount > 0)) {
            throw new InvalidArgumentException('The options tags, tag, parameters & parameter cannot be combined with the service name argument.');
        } elseif ((null === $name) && $optionsCount > 1) {
            throw new InvalidArgumentException('The options tags, tag, parameters & parameter cannot be combined together.');
        }
    }

    private function findProperServiceName(InputInterface $input, SymfonyStyle $io, ContainerBuilder $container, string $name, bool $showHidden): string
    {
        $name = ltrim($name, '\\');

        if ($container->has($name) || !$input->isInteractive()) {
            return $name;
        }

        $matchingServices = $this->findServiceIdsContaining($container, $name, $showHidden);
        if (!$matchingServices) {
            throw new InvalidArgumentException(\sprintf('No services found that match "%s".', $name));
        }

        if (1 === \count($matchingServices)) {
            return $matchingServices[0];

View on GitHub (pinned to 698e28026c)

Solutions

  1. Run separate commands for each piece of information you need.
  2. Pick the single most relevant option and remove the others from the command line.

Example fix

// before
php bin/console debug:container --tags --parameters

// after
php bin/console debug:container --tags
php bin/console debug:container --parameters
Defensive patterns

Strategy: validation

Validate before calling

// Enforce at most one listing option before running.
$exclusiveOpts = ['tags','tag','parameters','parameter'];
$used = array_filter($exclusiveOpts, fn($o) => $input->getOption($o));
if (count($used) > 1) {
    // pick the first and drop the rest, or reject
}

Try / catch

try {
    $command->run($input, $output);
} catch (\Symfony\Component\Console\Exception\InvalidArgumentException $e) {
    // inform user to choose a single option
}

Prevention

When it happens

Trigger: Running e.g. `php bin/console debug:container --tags --parameters`, `--tag=form.type --parameter=kernel.debug`, or any pair of the four listing options in a single invocation.

Common situations: Copy-pasting command flags from different recipes, shell history tab-completion bringing in a stale option, or wrapper scripts that blindly concatenate options.

Related errors


AI-assisted analysis of symfony/symfony@698e28026c (2026-08-06). Data as JSON: /api/errors/30d93af04123434f. Report an issue: GitHub.