symfony/symfony · error · Symfony\Component\DependencyInjection\Exception\InvalidArgumentException

The "marshaller" attribute of the "cache.pool" tag for servi

Error message

The "marshaller" attribute of the "cache.pool" tag for service "%s" is not supported by chained adapter "%s".

What it means

CachePoolPass supports a 'marshaller' attribute on the cache.pool tag to inject a custom serializer (e.g. for igbinary or encrypted marshalling). For chained adapters, the marshaller is injected into each constituent adapter. If a chained adapter does not wire 'cache.default_marshaller' in its constructor arguments (meaning it has no marshaller slot) and it is not ArrayAdapter or NullAdapter (which legitimately don't need one), the pass cannot inject the marshaller and throws an InvalidArgumentException at compile time.

Source

Thrown at src/Symfony/Component/Cache/DependencyInjection/CachePoolPass.php:145

                        $chainedPool->replaceArgument($i++, $tags[0]['namespace']);
                    }

                    if (isset($tags[0]['default_lifetime'])) {
                        $defaultLifetime = $tags[0]['default_lifetime'];

                        if (!is_numeric($defaultLifetime)) {
                            $defaultLifetime = (new Definition('int', [$defaultLifetime]))
                                ->setFactory([ParameterNormalizer::class, 'normalizeDuration']);
                        }

                        $chainedPool->replaceArgument($i++, $defaultLifetime);
                    }

                    if (null !== $marshallerServiceId) {
                        if (null !== $marshallerIndex = $this->findDefaultMarshallerArgumentIndex($adapter)) {
                            $chainedPool->replaceArgument($marshallerIndex, new Reference($marshallerServiceId));
                        } elseif (!\in_array($chainedClass, [ArrayAdapter::class, NullAdapter::class], true)) {
                            throw new InvalidArgumentException(\sprintf('The "marshaller" attribute of the "cache.pool" tag for service "%s" is not supported by chained adapter "%s".', $id, $chainedClass));
                        }
                    }

                    $adapters[] = $chainedPool;
                }

                $pool->replaceArgument(0, $adapters);
                unset($tags[0]['provider'], $tags[0]['namespace']);
                $i = 1;
            } else {
                $i = 0;
            }

            foreach ($attributes as $attr) {
                if (!isset($tags[0][$attr])) {
                    // no-op
                } elseif ('reset' === $attr) {
                    if ($tags[0][$attr]) {

View on GitHub (pinned to 698e28026c)

Solutions

  1. Remove the 'marshaller' attribute from the cache.pool tag for this service.
  2. Ensure each chained adapter's service definition wires 'cache.default_marshaller' as a constructor argument (check findDefaultMarshallerArgumentIndex logic).
  3. Use only built-in adapters (RedisAdapter, PdoAdapter, etc.) in the chain, which already wire the marshaller argument.
  4. Add cache.default_marshaller as a constructor argument to your custom adapter definition.

Example fix

// before
my_custom_adapter:
    class: App\Cache\MyCustomAdapter
    arguments: ['%dsn%']
    tags:
        - { name: cache.pool, marshaller: my.marshaller }

// after — wire the marshaller argument
my_custom_adapter:
    class: App\Cache\MyCustomAdapter
    arguments: ['%dsn%', '@cache.default_marshaller']
    tags:
        - { name: cache.pool, marshaller: my.marshaller }
Defensive patterns

Strategy: validation

Validate before calling

// In services.yaml: ensure chained adapters wire cache.default_marshaller
# my.adapter:
#     arguments: ['%dsn%', '@cache.default_marshaller']
# Only then add: tags: [{ name: cache.pool, marshaller: my.marshaller }]

Prevention

When it happens

Trigger: Tagging a ChainAdapter-based pool with { marshaller: 'my.marshaller' } when one of the chained adapters is a custom adapter class whose definition does not accept cache.default_marshaller as a constructor argument.

Common situations: Using a custom adapter class in a chain that doesn't follow the standard Symfony adapter constructor signature, or removing the marshaller argument from a stock adapter definition override.

Related errors


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