symfony/http-foundation · error · RuntimeException

The " " HTTP header is not parseable ( ).

Error message

The "%s" HTTP header is not parseable (%s).

What it means

A RuntimeException thrown by HeaderBag::getDate() when the named header exists but its value cannot be parsed with DateTimeImmutable::createFromFormat(DATE_RFC2822, ...). The header value at fault is the malformed date string (e.g. a corrupt Expires or Last-Modified header); it is not raised when the header is absent (the $default path applies instead).

Solutions

  1. Catch the RuntimeException and fall back to the $default argument or a safe timestamp
  2. Sanitize or correct the header value so it conforms to RFC 2822 before calling getDate()
  3. Use HeaderBag::get() plus DateTimeImmutable::createFromFormat manually with more lenient formats
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at HeaderBag.php:197 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/17cbc09e553ada48. Report an issue: GitHub.

Appendix: source

Thrown at HeaderBag.php:197

    public function getDate(string $key, ?\DateTimeInterface $default = null): ?\DateTimeImmutable
    {
        if (null === $value = $this->get($key)) {
            return null !== $default ? \DateTimeImmutable::createFromInterface($default) : null;
        }

        if (false === $date = \DateTimeImmutable::createFromFormat(\DATE_RFC2822, $value)) {
            throw new \RuntimeException(\sprintf('The "%s" HTTP header is not parseable (%s).', $key, $value));
        }

        return $date;
    }

View on GitHub (pinned to 5aea19cd67)