Skip to content

Conversation

@calebdw
Copy link
Contributor

@calebdw calebdw commented Jul 19, 2024

Hello!

I finally tracked down the root cause for the existing json errors in #52188.

When a FormRequest is resolved from the container it calls the FormRequest::createFrom() method with the Request object that, among other things, sets the FormRequest json from the Request json.

In the case where the Request does not have any content the Request::json() method is trying to decode an empty string as an associative array which results in a json syntax error.

This PR fixes that error by converting the empty string to an empty json array before decoding.

Thanks!

@calebdw calebdw changed the title fix: Request::json() json errors when decoding empty string [11.x] fix: Request::json() json errors when decoding empty string Jul 19, 2024
@taylorotwell taylorotwell merged commit ee1166c into laravel:11.x Jul 22, 2024
@calebdw calebdw deleted the request_json branch July 22, 2024 14:34
@calebdw
Copy link
Contributor Author

calebdw commented Jul 22, 2024

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants