symfony/http-kernel · error · RuntimeException

Unable to store the metadata.

Error message

Unable to store the metadata.

What it means

After persisting the response body, Store::write() serializes the request env and response headers as the cache metadata and calls save() on the metadata key. If that save fails, the RuntimeException is thrown because a cache entry without metadata is unusable.

Solutions

  1. Make the cache directory writable by the web/PHP user
  2. Free disk space or increase quota
  3. Clear the cache (rm -rf var/cache or cache:clear) after fixing permissions
Defensive patterns

Strategy: try-catch

Validate before calling

is_dir($cacheDir) && is_writable($cacheDir) || throw new \RuntimeException("Cache dir $cacheDir not writable");

Try / catch

try {
    $store->write($request, $response);
} catch (\RuntimeException $e) {
    $logger->error('HTTP cache metadata write failed: '.$e->getMessage());
    return $response;
}

Prevention

When it happens

Trigger: Store::save($key, serialize($entries)) returns false during write(): unwritable or full cache storage, or a custom Store overriding save() with failing behavior for the metadata key.

Common situations: Same filesystem issues as entity storage but discovered while writing the metadata file: permissions after deploys (different deploy user), read-only mounts, disk full.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


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

Appendix: source

Thrown at HttpCache/Store.php:232

        $entries = [];
        $vary = implode(', ', $response->headers->all('vary'));
        foreach ($this->getMetadata($key) as $entry) {
            if (!$this->requestsMatch($vary ?? '', $entry[0], $storedEnv)) {
                $entries[] = $entry;
            }
        }

        $headers = $this->persistResponse($response);
        unset($headers['age']);

        foreach ($this->options['private_headers'] as $h) {
            unset($headers[strtolower($h)]);
        }

        array_unshift($entries, [$storedEnv, $headers]);

        if (!$this->save($key, serialize($entries))) {
            throw new \RuntimeException('Unable to store the metadata.');
        }

        return $key;
    }

    /**
     * Returns content digest for $response.
     */
    protected function generateContentDigest(Response $response): string
    {
        return 'en'.hash('xxh128', $response->getContent());
    }

    /**
     * Invalidates all cache entries that match the request.
     *
     * @throws \RuntimeException
     */

View on GitHub (pinned to aa3a39d728)