Seldaek/monolog · error · InvalidArgumentException

extra must be an array

Error message

extra must be an array

What it means

Error "extra must be an array" thrown in Seldaek/monolog.

Source

Thrown at src/Monolog/LogRecord.php:46

    public function __construct(
        public readonly \DateTimeImmutable $datetime,
        public readonly string $channel,
        public readonly Level $level,
        public readonly string $message,
        /** @var array<mixed> */
        public readonly array $context = [],
        /** @var array<mixed> */
        public array $extra = [],
        public mixed $formatted = null,
    ) {
    }

    public function offsetSet(mixed $offset, mixed $value): void
    {
        if ($offset === 'extra') {
            if (!\is_array($value)) {
                throw new \InvalidArgumentException('extra must be an array');
            }

            $this->extra = $value;

            return;
        }

        if ($offset === 'formatted') {
            $this->formatted = $value;

            return;
        }

        throw new \LogicException('Unsupported operation: setting '.$offset);
    }

    public function offsetExists(mixed $offset): bool
    {

View on GitHub (pinned to 57eb102834)

When it happens

Trigger: Thrown at src/Monolog/LogRecord.php:46 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Seldaek/monolog@57eb102834 (2026-08-17). Data as JSON: /api/errors/1a9d7af17c6c23e3. Report an issue: GitHub.