Laravel-debugbar: Laravel Validation Errors Not Displayed in Session Tab

Created on 29 Apr 2019  ·  17Comments  ·  Source: barryvdh/laravel-debugbar

The validation error messages used to display in the debugbar's session tab but now it is not visible while other variables are present as they should. But when I dd(session()->all()). The error bag is there and displays all the validation errors and messages as expected.

I suspect it happened after upgrading to Laravel 5.8 from 5.7.
Please Help.

Currently Using Laravel 5.8.14
Debugbar 3.2.3
On WIndows 10

stale

Most helpful comment

Hey @barryvdh any news on this? Would be appreciated to solve this bug 😊

All 17 comments

Same here.
Laravel 5.8.14
Debugbar 3.2.3
Fedora 29
Php 7.2.14

Here too.

-Laravel 5.8.23
-Debugbar 3.2.4
-PHP Version: 7.2.17
-Ubuntu 18.04.2 LTS

Any progress on this?

Similarly:
-Laravel 5.8.33
-Debugbar 3.2.7
-Homestead (Ubuntu 18.04, PHP 7.3.7)

return back()
->withErrors(['msg' => "Error message"])
->withInput();

1

Here too.

-Laravel 6x
-Debugbar 3.2.x
-PHP Version: 7.3.10
-Ubuntu 18.04.2 LTS

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If this issue is still present on the latest version of this library on supported Laravel versions, please let us know by replying to this issue so we can investigate further.
Thank you for your contribution! Apologies for any delayed response on our side.

It's more than an year since I posted the issue, but no progress...the issue still persists in the latest version.

@barryvdh any progress on this?

Hello!
I found the solution (not brilliant but works)
in file Http/Kernel.php move Middlewares:

\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,

from $middlewareGroups => ['web'=>[/* was here */]]
to protected $middleware = [/* now moved to this place */]

Снимок экрана 2020-09-05 в 14 19 05

and errorBag show in session:
Снимок экрана 2020-09-05 в 14 14 20

@evd1ser It's an ugly hack but it works. So when we go for production, can we move those back since debugbar is only meant for development?

@evd1ser It's an ugly hack but it works. So when we go for production, can we move those back since debugbar is only meant for development?

Yes, its only for Debugbar work =)

Still wish it is patched in future versions of debugbar.

Not really sure, so the issue is that validation errors are never visible?

The usecase I have is for ensuring QueryException is handled properly. In my UserController,

try {
    // This will throw QueryException
    $newUser = $this->userService->saveUser($userInfo);
} catch(\Throwable $e) {
    return redirect()
        ->route('dashboard.user.showForm')
        ->withError('Something went wrong. Please contact your administrator');
}

Something like this. So if I don't do as @evd1ser as suggested, that error message never shows up.

The problem is that session variables end up seem to end up in the wrong request.

Suppose I edit some model. First I do a GET request to the Model/Edit route. Then I do a POST request to the Model/Update route. This generates an error, which generates another GET request to the Model/Edit route:

Screenshot 2020-09-09 at 10 43 38

What used to happen (a couple of Laravel versions ago I guess) was that the error messagebag and the old input and other session variables would be visible in Debugbar in the second GET request, which is automatically displayed after the error is generated and you are redirected, because it was the last request of course.

This isn't the case anymore. They now end up in the POST request, which you manually have to open in Debugbar.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If this issue is still present on the latest version of this library on supported Laravel versions, please let us know by replying to this issue so we can investigate further.
Thank you for your contribution! Apologies for any delayed response on our side.

Hey @barryvdh any news on this? Would be appreciated to solve this bug 😊

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MRZ2017 picture MRZ2017  ·  3Comments

truongthaison picture truongthaison  ·  4Comments

knvpk picture knvpk  ·  5Comments

ddmo picture ddmo  ·  3Comments

thomthom picture thomthom  ·  5Comments