8000 Httpclient produces difficult to debug message when no scheme is present · Issue #39285 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
Httpclient produces difficult to debug message when no scheme is present #39285
Closed
@BackEndTea

Description

@BackEndTea

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).

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

      0