symfony/http-kernel · error · InvalidArgumentException

Cache pool not found

Error message

Cache pool not found: "%s".

What it means

Psr6CacheClearer::getPool() looks up a registered PSR-6 cache pool service by its name and throws InvalidArgumentException when no pool with that name is registered. It exists so cache:clear and user code fail loudly instead of returning a null pool.

Solutions

  1. Check the exact pool name against registered pools: call hasPool($name) or inspect services tagged cache.pool (debug:container --tag=cache.pool).
  2. Fix the typo or use the pool's alias (e.g. 'cache.app') instead of the literal service id.
  3. Ensure the pool service is defined and tagged with kernel.cache_clearer-injected 'cache.pool' in your config for the current environment.

Example fix

// before
$pool = $clearer->getPool('app_result_cache');
// after
if ($clearer->hasPool('app_result_cache')) {
    $pool = $clearer->getPool('app_result_cache');
}
Defensive patterns

Strategy: type-guard

Validate before calling

if (!$cacheClearer->hasPool($name)) { throw new \DomainException("Unknown pool $name"); }
$pool = $cacheClearer->getPool($name);

Type guard

function getPoolSafe(Psr6CacheClearer $c, string $name): ?CacheItemPoolInterface
{
    return $c->hasPool($name) ? $c->getPool($name) : null;
}

Try / catch

try { $pool = $clearer->getPool($name); } catch (\InvalidArgumentException $e) { $pool = null; }

Prevention

When it happens

Trigger: Calling $cacheClearer->getPool('my_pool') when the pool name is not among the pools injected into Psr6CacheClearer (tagged 'cache.pool' services), including misspelled names or pools removed from the container.

Common situations: Typo in pool name; pool service missing the cache.pool tag or its 'pool' alias removed; running in an environment where the pool was excluded from the container; code written against a pool that a bundle no longer defines.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of symfony/http-kernel@aa3a39d728 (2026-09-13). Data as JSON: /api/errors/8ae448612ba102e5. Report an issue: GitHub.

Appendix: source

Thrown at CacheClearer/Psr6CacheClearer.php:42

     * @param array<string, CacheItemPoolInterface> $pools
     */
    public function __construct(array $pools = [])
    {
        $this->pools = $pools;
    }

    public function hasPool(string $name): bool
    {
        return isset($this->pools[$name]);
    }

    /**
     * @throws \InvalidArgumentException If the cache pool with the given name does not exist
     */
    public function getPool(string $name): CacheItemPoolInterface
    {
        if (!$this->hasPool($name)) {
            throw new \InvalidArgumentException(\sprintf('Cache pool not found: "%s".', $name));
        }

        return $this->pools[$name];
    }

    /**
     * @throws \InvalidArgumentException If the cache pool with the given name does not exist
     */
    public function clearPool(string $name): bool
    {
        if (!isset($this->pools[$name])) {
            throw new \InvalidArgumentException(\sprintf('Cache pool not found: "%s".', $name));
        }

        return $this->pools[$name]->clear();
    }

    public function clear(string $cacheDir): void

View on GitHub (pinned to aa3a39d728)