Skip to content

Non descriptive error message in URL parsing #1986

@zjpetersen

Description

@zjpetersen

Hello, today I got an issue where undici was throwing an error: InvalidArgumentError: invalid protocol

This turned out to be due to having my http_proxy as http_proxy=proxy.company.com:port
Instead, undici was expecting it to have http:// at the start. http_proxy=http://proxy.company.com:port

undici/lib/core/util.js

Lines 81 to 83 in 4885b11

if (!/^https?:/.test(url.origin || url.protocol)) {
throw new InvalidArgumentError('invalid protocol')
}

I was able to figure out the issue by looking at the code, but this is not a good user experience. I've been using my proxy without the http:// prefix for years so this was a bit strange. I don't know enough about this library to say if URLs without http:// or https:// should be accepted, but at the very least there should be a more descriptive error message saying that you're missing the http prefix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions