oven-sh/bun

Misleading error message "URL must not be a blank string" when URL is a non-string value which does not stringify to a fully valid URL with a hostname

Open

#21361 opened on Jul 24, 2025

View on GitHub
 (6 comments) (1 reaction) (0 assignees)Rust (90,348 stars) (4,486 forks)batch import
bugconfirmed buggood first issueweb:fetch

Description

What version of Bun is running?

1.2.18+0d4089ea7

What platform is your computer?

Darwin 24.3.0 arm64 arm

What steps can reproduce the bug?

Any of the following (and more):

await fetch(undefined)
await fetch(123)
await fetch({toString() {return `/some_path`}})

What is the expected behavior?

Something more precise, like:

fetch() URL must have a hostname

What do you see instead?

fetch() URL must not be a blank string

Additional information

Link to offending line in Bun sources: https://github.com/oven-sh/bun/blob/bd232189b4c39ac3c8ccef9cf0932407d65c527a/src/bun.js/webcore/fetch.zig#L1448

Contributor guide