{"record":{"id":"e81a4a322e3b0304","repo":"Hmbown/CodeWhale","slug":"browser-url-cannot-be-empty","errorCode":null,"errorMessage":"browser URL cannot be empty","messagePattern":"browser URL cannot be empty","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/utils.rs","lineNumber":513,"sourceCode":"/// - Windows: `cmd /C start \"\"`\n/// - Other: returns an error.\n///\n/// This is the single entry point for URL opening — every call site in\n/// the codebase should use this instead of hardcoding `Command::new(\"open\")`,\n/// `Command::new(\"xdg-open\")`, or `Command::new(\"cmd\")`.\npub fn open_url(url: &str) -> Result<()> {\n    let mut command = browser_open_command(url)?;\n    command\n        .stdout(std::process::Stdio::null())\n        .stderr(std::process::Stdio::null())\n        .spawn()\n        .map(|_| ())\n        .map_err(|e| anyhow::anyhow!(\"failed to launch browser command: {e}\"))\n}\n\nfn browser_open_command(url: &str) -> Result<Command> {\n    if url.trim().is_empty() {\n        return Err(anyhow::anyhow!(\"browser URL cannot be empty\"));\n    }\n\n    #[cfg(target_os = \"macos\")]\n    {\n        let mut command = Command::new(\"open\");\n        command.arg(url);\n        Ok(command)\n    }\n\n    #[cfg(any(\n        all(target_os = \"linux\", not(target_env = \"ohos\")),\n        target_os = \"netbsd\",\n        target_os = \"freebsd\",\n        target_os = \"openbsd\",\n        target_os = \"dragonfly\"\n    ))]\n    {\n        let mut command = Command::new(\"xdg-open\");","sourceCodeStart":495,"sourceCodeEnd":531,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/utils.rs#L495-L531","documentation":"Guard in open_url, the single codebase-wide entry point for opening URLs: the url argument was empty or whitespace-only. An empty URL would be handed to the platform open command (open/xdg-open/cmd /C start) and fail opaquely there, so it is rejected up front before a browser command is built.","triggerScenarios":"Thrown at crates/tui/src/utils.rs:513 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the URL is non-empty before calling open_url.","Check upstream data flow so the link variable is populated from the actual event or response."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}