BoundaryML/baml · error · RuntimeError

Invalid argument: {name}

Error message

Invalid argument: {name}

What it means

RuntimeError::InvalidArgument is raised when a caller passes a runtime API parameter that the bex_project layer rejects; the `name` field identifies the offending argument. It signals a caller-side input problem rather than an internal failure.

Source

Thrown at baml_language/crates/bex_project/src/lib.rs:91

    }
}

impl From<IndexMap<String, BexExternalValue>> for BexArgs {
    fn from(required: IndexMap<String, BexExternalValue>) -> Self {
        Self {
            required,
            optional: IndexMap::new(),
        }
    }
}

/// Errors that can occur during runtime operations.
#[derive(Debug, Error)]
pub enum RuntimeError {
    #[error("{0}")]
    Other(String),

    #[error("Invalid argument: {name}")]
    InvalidArgument { name: String },

    #[error("{message}")]
    Compilation { message: String },

    #[error("{0}")]
    Engine(#[from] bex_engine::EngineError),

    #[error("Failed to convert result to owned value: {0}")]
    Access(#[from] bex_heap::AccessError),
}

/// True iff `err` wraps an engine cancellation panic.
///
/// Centralizes the cancellation-classification logic that bridges and the
/// LSP server need to distinguish cancellation from other runtime errors.
pub fn is_cancelled_runtime_error(err: &RuntimeError) -> bool {
    matches!(err, RuntimeError::Engine(e) if is_cancelled_engine_error(e))

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Check the `name` field to see which argument was rejected and verify it against the API's expected values.
  2. Validate arguments (non-empty, correct format/identifier rules) before invoking the runtime API.
  3. Update call sites if a library upgrade renamed or re-typed the argument.
  4. Log the full argument set at the call site to spot typos or stale values.

Example fix

// before
project.run("")?; // RuntimeError::InvalidArgument { name: "..." }
// after
let name = "myFunction";
assert!(!name.is_empty());
project.run(name)?;
Defensive patterns

Strategy: validation

Validate before calling

fn ensure_valid_arg(name: &str, value: &str) -> Result<(), String> {
    if name.is_empty() { return Err("argument name empty".into()); }
    if value.is_empty() { return Err(format!("argument '{name}' must be non-empty")); }
    Ok(())
}
// call before invoking the runtime API

Try / catch

match project.run(arg) {
    Err(RuntimeError::InvalidArgument { name }) => {
        eprintln!("rejecting bad argument '{name}'; check spelling and format");
    }
    other => other?,
}

Prevention

When it happens

Trigger: Calling a bex_project runtime function with a named argument that is empty, malformed, unknown, or violates the API's contract — e.g. passing an invalid function/parameter/variable name or a misnamed option.

Common situations: Typos in argument names; passing user-supplied input straight into runtime APIs without validation; calling with Option/None or empty strings where a concrete value is required; API version changes renaming accepted arguments.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12). Data as JSON: /api/errors/81e64732becc4c36. Report an issue: GitHub.