astrid-runtime/astrid · error

Unsafe WASM artifact name

Error message

Unsafe WASM artifact name: {output_name}

What it means

Fired by validate_wasm_output_name when the cdylib output name is not a single safe path component (e.g. contains `/`, `..`, or is otherwise path-hostile). Prevents manifest/archive paths from escaping the package layout.

Solutions

  1. Rename the library with `[lib] name = "simple_name"` using only safe identifier characters
  2. Remove path separators or traversal sequences from the output name
  3. Rebuild after fixing the name
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/astrid-build/src/rust.rs:182 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09). Data as JSON: /api/errors/a4433551c2eaf983. Report an issue: GitHub.

Appendix: source

Thrown at crates/astrid-build/src/rust.rs:182

    I: IntoIterator<Item = String>,
{
    let output_names: Vec<String> = output_names.into_iter().collect();
    match output_names.as_slice() {
        [] => bail!("Capsule has no cdylib target; refusing to guess a WASM artifact"),
        [output_name] => validate_wasm_output_name(output_name),
        _ => bail!(
            "Capsule has {} cdylib targets; refusing to choose an ambiguous WASM artifact",
            output_names.len()
        ),
    }
}

fn validate_wasm_output_name(output_name: &str) -> Result<String> {
    let path = Path::new(output_name);
    let is_single_normal_component =
        output_name != "." && output_name != ".." && path.file_name() == Some(path.as_os_str());
    if !is_single_normal_component {
        bail!("Unsafe WASM artifact name: {output_name}");
    }
    Ok(output_name.to_owned())
}

/// Compile the capsule in release mode using whatever target Cargo resolves
/// from its complete configuration hierarchy.
///
/// The Astrid-canonical target is `wasm32-unknown-unknown` — zero
/// `wasi:*` imports, every host call audited through the
/// `astrid:*` SDK surface. Capsules may also target `wasm32-wasip2`
/// during the migration window (the kernel still satisfies wasi:*
/// for backwards compatibility), so this build step does NOT pass
/// `--target`; it lets Cargo's own config and environment precedence decide.
///
/// When the capsule targets `wasm32-unknown-unknown` it additionally
/// injects the getrandom custom-backend cfg through target-wide rustflags so
/// `astrid build` succeeds even when a capsule's `.cargo/config.toml` is
/// missing `--cfg=getrandom_backend="custom"`. This is a safety net for the

View on GitHub (pinned to affd8760f4)