orchidsoftware / platform

Orchid is a @laravel package that allows for rapid application development of back-office applications, admin/user panels, and dashboards.
https://orchid.software
MIT License
4.26k stars 631 forks source link

Illuminate\Contracts\Encryption\DecryptException The payload is invalid. #2759

Closed ShamazinGG closed 6 months ago

ShamazinGG commented 6 months ago

PHP 8.3.0 Laravel 10.34.2 orchid/platform 14.15.0

Доброго времени суток. После обновления с 13 версии на 14 столкнулся с ошибкой Illuminate\Contracts\Encryption\DecryptException The payload is invalid Возникает только при попытке удаления сущности из списка сущностей(...ListScreen,...ListLayout) При дебаге выяснил, что ошибка возникает в методе extractState, класса src/Screen/Screen.php 200 В теле запроса присутствует пустое поле _state Соответственно падает при вызове return Crypt::decrypt($raw);, т.к в $raw null

Весь код метода:

    protected function extractState(): Repository
    {
        // Check if the '_state' parameter is missing
        if (! request()->request->has('_state') && session()->missing('_state')) {
            // Return an empty Repository object
            return new Repository();
        }

        // Extract the encrypted state from the '_state' parameter, and deserialize it
        $raw = request()->post('_state') ?? session()->get('_state');

        return Crypt::decrypt($raw);
    }

PR с потенциальным фиксом: https://github.com/orchidsoftware/platform/pull/2760 Буду благодарен за любой фидбэк

tabuna commented 6 months ago

In Laravel, there is a middleware called TrimStrings, which is enabled by default. This middleware automatically removes empty values, for example, <input name="_state"> should not be submitted.

However, in your project, a situation has arisen where this value has the null value. I'm not sure why this is happening. We recommend carefully checking the project settings to ensure that this value was not unintentionally set to null.

tabuna commented 6 months ago

In any case, I have merged your PR