Skip to main content
Adil Omer

6 Sep 2026 · laravel-debugbar

Getting validation errors back into the Debugbar session panel

Validation messages showed up as "_cut" because of a dumper depth limit. A pair of casters removed one level of nesting.

Issue #2036 showed the Debugbar session panel displaying validation errors as "_cut" instead of the actual messages, which is exactly the information you open that panel to find.

Where the depth went

SessionCollector formats session values through the data formatter, which uses Symfony's VarCloner with a depth limit of 3 for non-iterable objects. A ViewErrorBag needs four levels to reach its strings:

ViewErrorBag -> bags array -> MessageBag object -> messages array -> the strings

The MessageBag object uses up a whole level on its own, so the messages array appeared but everything inside it was replaced with "_cut".

The fix

The maintainer had suggested a custom caster in the issue. I registered two, next to the existing ones in registerDataFormatter(). They convert both bag types to plain arrays while cloning:

ViewErrorBag::class => static fn (ViewErrorBag $bag, array $a, Stub $stub): array =>
    array_map(fn (MessageBag $b): array => $b->toArray(), $bag->getBags()),
MessageBag::class => static fn (MessageBag $bag, array $a, Stub $stub): array =>
    $bag->toArray(),

The trade-off, which I stated in the PR: the dump loses the "MessageBag" class label and its format property, but you can read the messages. For what is essentially a list of strings, that is the right trade.

Testing

  • A test for the exact shape from the issue, plus a bare MessageBag, multiple named bags (the $errors->getBag('login') pattern) and the empty bag every view receives.
  • I reverted the caster locally and watched the tests fail with the same "_cut" output from the issue, so they actually catch the bug.
  • I left the more general "deep objects get cut" problem out of scope and said so, which kept the change small enough to review quickly.

Barry vd. Heuvel merged it the same day.