laravel / pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.
https://pulse.laravel.com
MIT License
1.47k stars 171 forks source link

Volt component in Volt route throws "htmlspecialchars(): Argument #1 ($string) must be of type string, stdClass given." in Slow Requests Card #391

Closed pa2codes closed 5 months ago

pa2codes commented 5 months ago

Pulse Version

1.2.3

Laravel Version

11.10.0

PHP Version

8.3.7

Livewire Version

3.5.0

Database Driver & Version

MySQL 8

Description

Hi there,

Using Volt Route I get the same error that was already discussed in https://github.com/laravel/pulse/issues/249.

The Laravel Pulse Slow Requests card throws:

htmlspecialchars(): Argument #1 ($string) must be of type string, stdClass given.

The issue seems my Volt Route Volt::route('/mok-event-shop/{event}', 'pages.shop.event-shop')->name('event-shop-page');

but after some debugging I found that within the event-shop.blade.php file

<livewire:pages.shop.product-category-filter :event="$event"/> and <livewire:pages.shop.product-list :event="$event"/>

seems to be the issue. if I remove them, no error is thrown. Both are Volt components. Here is my

event-shop.blade.php

use Livewire\Volt\Component;

new class extends Component {

    #[\Livewire\Attributes\Locked]
    public \App\Models\Event $event;

    public function mount($event):void
    {
        $this->authorize('shop', $event);
    }

}; ?>
<div>
...some html code...
<!-- Filters -->
<div class="hidden lg:block">
    <!-- Categories -->
    <livewire:pages.shop.product-category-filter :event="$event"/>
    <!-- More Filters -->
</div>
<!-- Product grid -->
<div class="lg:col-span-3">
    <div class="max-w-full mx-auto sm:px-6 lg:px-8">
        <div class="bg-white dark:bg-gray-800 overflow-hidden sm:rounded-lg">
            <div class="p-6 text-gray-900 dark:text-gray-100">
                <livewire:pages.shop.product-list :event="$event"/>
            </div>
        </div>
    </div>
</div>

The related Puls DB Table entry is '["GET","\/mok-event-shop\/{event}",{}]' image

I am not sure if its an issue with my code/setup or a bug.

I appreciate your help.

Thanks :)

Steps To Reproduce

  1. Create a Volt component to show events
  2. Setup a Volt route with event param pointing to component from 1.
  3. Create another Volt Component product-list that uses event param.
  4. Call product-list component in the event component and pass event as param.
crynobone commented 5 months ago

Hey there, thanks for reporting this issue.

We'll need more info and/or code to debug this further. Can you please create a repository with the command below, commit the code that reproduces the issue as one separate commit on the main/master branch and share the repository here?

Please make sure that you have the latest version of the Laravel installer in order to run this command. Please also make sure you have both Git & the GitHub CLI tool properly set up.

laravel new bug-report --github="--public"

Do not amend and create a separate commit with your custom changes. After you've posted the repository, we'll try to reproduce the issue.

Thanks!

driesvints commented 5 months ago

Closing this issue because it's inactive, already solved, old or not relevant anymore. Feel to open up a new issue if you're still experiencing this.