Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Httpclient produces difficult to debug message when no scheme is present #39285

Copy link
Copy link
Closed
@BackEndTea

Description

@BackEndTea
Issue body actions

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.