You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have updated laravel/framework to latest stable version and encountered an issue, that originally occurred in version 10.29.0. When communicating with server API, following error occurs:
Symfony\Component\HttpFoundation\Exception\JsonException
Could not decode request body.
It happens in Illuminate\Routing\RoutingServiceProvider class:
protected function registerPsrRequest()
{
$this->app->bind(ServerRequestInterface::class, function ($app) {
if (class_exists(Psr17Factory::class) && class_exists(PsrHttpFactory::class)) {
$psr17Factory = new Psr17Factory;
return with((new PsrHttpFactory($psr17Factory, $psr17Factory, $psr17Factory, $psr17Factory))
->createRequest($illuminateRequest = $app->make('request')), fn ($request) => $request->withParsedBody(
array_merge($request->getParsedBody() ?? [], $illuminateRequest->getPayload()->all())
));
}
throw new BindingResolutionException('Unable to resolve PSR request. Please install the symfony/psr-http-message-bridge and nyholm/psr7 packages.');
});
}
Functionality was OK until version 10.28.0, but all newer version are causing us this error. The issue is in the getPayload() method, which handles the data as JSON, but in our case it is not a JSON, hence the error. The change originated in this pull request: https://github.com/laravel/framework/pull/48696/files
We haven't found any information in the release notes / migration guide, which could help us fix this issue, so we assume this might be a bug to report. If this is not an error, please advise how to fix this on our side.
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?
I've created the repository as suggested + created there a single controller with one method, which just tries to decode the gzipped json data from request body.
Link to repo: https://github.com/marekfri/laravel-bug-report
The issue is, I think, that in the getPayload() method, if data from getContent() is not empty, it is always tried to be json_decoded. But I don't think that we can just assume that the data will always be a json string.
Let me know if I can do anything further to help resolve this.
Laravel Version
10.29.0
PHP Version
8.1.2
Database Driver & Version
No response
Description
We have updated laravel/framework to latest stable version and encountered an issue, that originally occurred in version 10.29.0. When communicating with server API, following error occurs:
It happens in Illuminate\Routing\RoutingServiceProvider class:
Functionality was OK until version 10.28.0, but all newer version are causing us this error. The issue is in the getPayload() method, which handles the data as JSON, but in our case it is not a JSON, hence the error. The change originated in this pull request: https://github.com/laravel/framework/pull/48696/files
We haven't found any information in the release notes / migration guide, which could help us fix this issue, so we assume this might be a bug to report. If this is not an error, please advise how to fix this on our side.
Link to Sentry issue: https://crystal-missions.sentry.io/share/issue/5c43f0cf13e34684bf845dec4e123197/
Thank you.
Steps To Reproduce
We are sending a gziped JSON data to our server API endpoint.
The text was updated successfully, but these errors were encountered: