framework: Request::getPayload(): Return value must be of type InputBag, ParameterBag returned
Laravel Version
10.16.0
PHP Version
8.1.19
Database Driver & Version
No response
Description
Symfony\Component\HttpFoundation\Request::getPayload(): Return value must be of type Symfony\Component\HttpFoundation\InputBag, Symfony\Component\HttpFoundation\ParameterBag returned
This error now occurs as soon as Laravel tries to handle any JSON request. This seems to be based on the new symfony/psr-http-message-bridge
v2.3.0 release.
But originally it seems like a far longer problem just never detected. With Symfony 6 types were added - so also to the Symfony\Component\HttpFoundation\Request::getPayload()
method. But for Laravel 9 the payload of JSON requests was filled into a ParameterBag
. All places not checking for explicit type won’t have any problem as these classes have nearly identical APIs.
- https://github.com/symfony/psr-http-message-bridge/pull/117
- https://github.com/laravel/framework/blob/55ccc3a9579f8f58435ec391c38b0a9fc78bb89e/src/Illuminate/Http/Request.php#L489-L491
- https://github.com/laravel/framework/pull/37921
- https://github.com/symfony/symfony/blob/86c41bb42594e59bfec16df29e0829eb7e850431/src/Symfony/Component/HttpFoundation/Request.php#L1514
Steps To Reproduce
Send a JSON request to the server with "symfony/psr-http-message-bridge": "2.3.0"
installed.
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 13
- Comments: 24 (11 by maintainers)
I’ve found the issue. Putting together a PR to fix the issue.
Thanks for the quick fixes! 👍🏻
quick workaround. add to composer.json under require: “symfony/http-foundation”: “6.2”,
See: https://github.com/laravel/framework/pull/47840
Thanks for the hard work @timacdonald 👏🏼