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

  1. Fix the url in the source pake.json to an absolute, valid URL with scheme (https://...).
  2. Re-run the pake CLI build so the corrected config is embedded.
  3. 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

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


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)