tw93/Pake · critical · tauri::Error
Invalid 'web' url ' ' in pake.json
Error message
Invalid 'web' url '{}' in pake.json: {err} What it means
When pake.json declares url_type 'web', build_window_with_label parses the url string into a tauri::Url (WebviewUrl::External); a malformed URL aborts window creation with this formatted error containing the offending value and the underlying parse error.
Solutions
- Fix the url in the source pake.json to an absolute, valid URL with scheme (https://...).
- Re-run the pake CLI build so the corrected config is embedded.
- If passing via CLI, quote the URL and percent-encode special characters.
Example fix
// before (pake.json)
{ "url": "example com", "url_type": "web" }
// after
{ "url": "https://example.com", "url_type": "web" } Defensive patterns
Strategy: validation
Validate before calling
const u = new URL(cfg.url);
if (!/^https?:$/.test(u.protocol)) throw new Error(`web url must be absolute http(s): ${cfg.url}`); Type guard
const isValidWebUrl = (s) => { try { const u = new URL(s); return u.protocol === 'https:' || u.protocol === 'http:'; } catch { return false; } }; Try / catch
match build_window_with_label(...) { Err(e) if e.to_string().contains("Invalid 'web' url") => eprintln!("fix url in pake.json: {e}"), Err(e) => return Err(e), Ok(w) => w } Prevention
- Always pass fully-qualified http(s) URLs to the pake CLI and quote them in shells
- URL-encode path segments with special characters before building
- Validate the URL with new URL() in the packaging step before writing pake.json
When it happens
Trigger: set_window or open_additional_window runs with a windows[0].url that fails Url::parse, e.g. missing scheme, invalid characters, or whitespace.
Common situations: User passes an unescaped URL via the CLI (spaces, unicode); config hand-edited to 'example.com' without https://; shell quoting mangling the URL at build time.
Understand the failure class
Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.
Related errors
- Failed to parse tauri config
- pake.json must define at least one window configuration
- url_type must be 'web' or 'local', got
- about:blank must be a valid URL
- Failed to parse pake config
AI-assisted analysis of tw93/Pake@c8fe8a3f1a (2026-09-20).
Data as JSON: /api/errors/b0f35a4d0adfdf03.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/src/app/window.rs:346
}
}
fn build_window_with_label(
app: &AppHandle,
config: &PakeConfig,
tauri_config: &Config,
label: &str,
) -> tauri::Result<WebviewWindow> {
let window_config = config.windows.first().ok_or_else(|| {
tauri::Error::Io(std::io::Error::new(
std::io::ErrorKind::InvalidData,
"pake.json must define at least one window configuration",
))
})?;
let url = match window_config.url_type.as_str() {
"web" => {
let parsed = window_config.url.parse().map_err(|err| {
tauri::Error::Io(std::io::Error::new(
std::io::ErrorKind::InvalidInput,
format!(
"Invalid 'web' url '{}' in pake.json: {err}",
window_config.url
),
))
})?;
WebviewUrl::App(parsed)
}
"local" => WebviewUrl::App(PathBuf::from(&window_config.url)),
other => {
return Err(tauri::Error::Io(std::io::Error::new(
std::io::ErrorKind::InvalidInput,
format!("url_type must be 'web' or 'local', got '{other}'"),
)));
}
};
View on GitHub (pinned to c8fe8a3f1a)