tw93/Pake · critical · tauri::Error

url_type must be 'web' or 'local', got

Error message

url_type must be 'web' or 'local', got '{other}'

What it means

build_window_with_label matches windows[0].url_type against only "web" and "local"; any other string returns an InvalidInput io error wrapped in tauri::Error. The url_type field is an enum-like contract of the pake.json schema.

Solutions

  1. Change url_type in pake.json to exactly 'web' or 'local' (lowercase).
  2. If the URL is remote use 'web'; for packaged local content use 'local' with a relative path in url.
  3. Rebuild via the pake CLI so the validated config is regenerated.

Example fix

// before (pake.json)
{ "url": "https://example.com", "url_type": "remote" }
// after
{ "url": "https://example.com", "url_type": "web" }
Defensive patterns

Strategy: validation

Validate before calling

if (!['web', 'local'].includes(cfg.url_type)) throw new Error(`url_type must be 'web' or 'local', got '${cfg.url_type}'`);

Type guard

const hasValidUrlType = (c) => c?.url_type === 'web' || c?.url_type === 'local';

Try / catch

match build_window_with_label(...) { Err(e) if e.to_string().contains("url_type must be") => eprintln!("fix url_type in pake.json: {e}"), Err(e) => return Err(e), Ok(w) => w }

Prevention

When it happens

Trigger: pake.json windows[0].url_type is set to a typo or unsupported value such as 'remote', 'file', 'Web', or '' and any window build (set_window, open_additional_window) is attempted.

Common situations: Hand-editing pake.json with wrong casing; a config generator emitting a new url_type not supported by this Pake version; copy-paste from another Tauri project's schema.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of tw93/Pake@c8fe8a3f1a (2026-09-20). Data as JSON: /api/errors/d37ca5376c5e3fbc. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/src/app/window.rs:358

            "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}'"),
            )));
        }
    };

    build_window(
        app,
        config,
        tauri_config,
        WindowBuildOptions {
            label,
            url,
            visible: false,
            new_window_features: None,
        },
    )
}

View on GitHub (pinned to c8fe8a3f1a)