Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non descriptive error message in URL parsing #1986

Closed
zjpetersen opened this issue Mar 3, 2023 · 3 comments · Fixed by #2016
Closed

Non descriptive error message in URL parsing #1986

zjpetersen opened this issue Mar 3, 2023 · 3 comments · Fixed by #2016

Comments

@zjpetersen
Copy link

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.

@mcollina
Copy link
Member

mcollina commented Mar 3, 2023

Thanks for reporting! Would you like to send a Pull Request to address this issue?

@zjpetersen
Copy link
Author

Sure I'd be happy to, do you just want the error message updated?

@mcollina
Copy link
Member

mcollina commented Mar 3, 2023

Yes, thanks!

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants