symfony/http-foundation · error · InvalidArgumentException

Unsupported Connection

Error message

Unsupported Connection: "%s".

What it means

An InvalidArgumentException thrown by SessionHandlerFactory::createHandler() when the given $connection is neither a recognized connection object (Redis, Relay, RedisArray, RedisCluster, Predis client, Memcached, PDO) nor a string DSN. The %s is filled with get_debug_type($connection), naming the unsupported type that was passed to the factory.

Solutions

  1. Pass a supported connection object (\Redis, Relay, \RedisArray, \RedisCluster, Predis\ClientInterface, \Memcached, \PDO) or a DSN string
  2. Cast the configured connection to a string DSN (e.g. 'redis://...', 'file://...') before calling the factory
  3. Check get_debug_type($connection) at the call site to find what wrong value is being injected
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at Session/Storage/Handler/SessionHandlerFactory.php:52 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of symfony/http-foundation@5aea19cd67 (2026-09-13). Data as JSON: /api/errors/5728b7636e56a2c0. Report an issue: GitHub.

Appendix: source

Thrown at Session/Storage/Handler/SessionHandlerFactory.php:52

            case $connection instanceof \RedisArray:
            case $connection instanceof \RedisCluster:
            case $connection instanceof \Predis\ClientInterface:
                return new RedisSessionHandler($connection);

            case $connection instanceof \Memcached:
                return new MemcachedSessionHandler($connection);

            case $connection instanceof \PDO:
                return new PdoSessionHandler($connection);

            case !\is_string($connection):
                throw new \InvalidArgumentException(\sprintf('Unsupported Connection: "%s".', get_debug_type($connection)));
            case str_starts_with($connection, 'file://'):
                $savePath = substr($connection, 7);

                return new StrictSessionHandler(new NativeFileSessionHandler('' === $savePath ? null : $savePath));

View on GitHub (pinned to 5aea19cd67)