Closed
Description
Symfony version(s) affected: 5.1.7
Description
When no base uri is set, and the url does not have a scheme, then you get a rather difficult to debug warning:
Trying to access array offset on value of type null
.
When the code continues after the waring (in production for example), an error is thrown with the following message:
Symfony\Component\HttpClient\Exception\TransportException: URL using bad/illegal format or missing URL for "//localhost:8080/".
How to reproduce
The following code should reproduce the error:
HttpClient::create()->request('GET', 'localhost:8080');
Possible Solution
Right now there is no check to see if the scheme is present, the code just assumes there is. A more detailed error
should be thrown, to let the user know.
The fix for the user is to change the url to http://localhost:8080
, but this may not be obvious right away (at least it wasn't for me).
apfelbox