Hmbown/CodeWhale · error
browser URL cannot be empty
Error message
browser URL cannot be empty
What it means
browser_open_command validates the URL before building the platform-specific Command and rejects empty or whitespace-only strings. This is a guard against spawning an opener with a blank argument, which would either fail downstream or open something unintended.
Solutions
- Ensure the caller supplies a non-empty URL before invoking open_url.
- Check the config/source of the URL string — it is likely empty because an upstream value is missing.
- Add a default URL or skip the open call when the URL is blank.
Example fix
// before
open_url(config.docs_url)?; // docs_url = ""
// after
if !config.docs_url.trim().is_empty() {
open_url(&config.docs_url)?;
} Defensive patterns
Strategy: validation
Validate before calling
if url.trim().is_empty() {
return; // skip opening; nothing to show
} Type guard
fn is_openable_url(url: &str) -> bool {
!url.trim().is_empty() && (url.starts_with("http://") || url.starts_with("https://"))
} Prevention
- Never pass config-derived URLs without checking they are non-empty.
- Provide default URLs in config so the field is never blank.
- Skip open calls entirely when the source field is empty.
When it happens
Trigger: Calling open_url("") or open_url(" "), or passing a URL variable that was never populated (failed extraction of a link from a response, empty config value).
Common situations: A config key for a docs/help URL left empty; code that builds the URL by string formatting where an upstream field was blank; tests passing an empty literal.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- bad_args
- base URL cannot be empty
- --base-url must use http or https
- classifier-approved read command was empty
- Codewhale account API base URL must be an origin without a…
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/e81a4a322e3b0304.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/utils.rs:616
/// - Windows: `cmd /C start ""`
/// - Other: returns an error.
///
/// This is the single entry point for URL opening — every call site in
/// the codebase should use this instead of hardcoding `Command::new("open")`,
/// `Command::new("xdg-open")`, or `Command::new("cmd")`.
pub fn open_url(url: &str) -> Result<()> {
let mut command = browser_open_command(url)?;
command
.stdout(std::process::Stdio::null())
.stderr(std::process::Stdio::null())
.spawn()
.map(|_| ())
.map_err(|e| anyhow::anyhow!("failed to launch browser command: {e}"))
}
fn browser_open_command(url: &str) -> Result<Command> {
if url.trim().is_empty() {
return Err(anyhow::anyhow!("browser URL cannot be empty"));
}
#[cfg(target_os = "macos")]
{
let mut command = Command::new("open");
command.arg(url);
Ok(command)
}
#[cfg(any(
all(target_os = "linux", not(target_env = "ohos")),
target_os = "netbsd",
target_os = "freebsd",
target_os = "openbsd",
target_os = "dragonfly"
))]
{
let mut command = Command::new("xdg-open");View on GitHub (pinned to 73e0f67d83)