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.

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)

Most upvoted comments

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”,

Thanks for the hard work @timacdonald 👏🏼