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

#21,361 建立於 2025年7月24日

在 GitHub 查看
 (6 留言) (1 反應) (0 負責人)Rust (90,348 star) (4,486 fork)batch import
bugconfirmed buggood first issueweb:fetch

描述

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

貢獻者指南