{"record":{"id":"81e64732becc4c36","repo":"BoundaryML/baml","slug":"invalid-argument-name","errorCode":null,"errorMessage":"Invalid argument: {name}","messagePattern":"Invalid argument: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"baml_language/crates/bex_project/src/lib.rs","lineNumber":91,"sourceCode":"    }\n}\n\nimpl From<IndexMap<String, BexExternalValue>> for BexArgs {\n    fn from(required: IndexMap<String, BexExternalValue>) -> Self {\n        Self {\n            required,\n            optional: IndexMap::new(),\n        }\n    }\n}\n\n/// Errors that can occur during runtime operations.\n#[derive(Debug, Error)]\npub enum RuntimeError {\n    #[error(\"{0}\")]\n    Other(String),\n\n    #[error(\"Invalid argument: {name}\")]\n    InvalidArgument { name: String },\n\n    #[error(\"{message}\")]\n    Compilation { message: String },\n\n    #[error(\"{0}\")]\n    Engine(#[from] bex_engine::EngineError),\n\n    #[error(\"Failed to convert result to owned value: {0}\")]\n    Access(#[from] bex_heap::AccessError),\n}\n\n/// True iff `err` wraps an engine cancellation panic.\n///\n/// Centralizes the cancellation-classification logic that bridges and the\n/// LSP server need to distinguish cancellation from other runtime errors.\npub fn is_cancelled_runtime_error(err: &RuntimeError) -> bool {\n    matches!(err, RuntimeError::Engine(e) if is_cancelled_engine_error(e))","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/bex_project/src/lib.rs#L73-L109","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check the `name` field to see which argument was rejected and verify it against the API's expected values.","Validate arguments (non-empty, correct format/identifier rules) before invoking the runtime API.","Update call sites if a library upgrade renamed or re-typed the argument.","Log the full argument set at the call site to spot typos or stale values."],"exampleFix":"// before\nproject.run(\"\")?; // RuntimeError::InvalidArgument { name: \"...\" }\n// after\nlet name = \"myFunction\";\nassert!(!name.is_empty());\nproject.run(name)?;","handlingStrategy":"validation","validationCode":"fn ensure_valid_arg(name: &str, value: &str) -> Result<(), String> {\n    if name.is_empty() { return Err(\"argument name empty\".into()); }\n    if value.is_empty() { return Err(format!(\"argument '{name}' must be non-empty\")); }\n    Ok(())\n}\n// call before invoking the runtime API","typeGuard":null,"tryCatchPattern":"match project.run(arg) {\n    Err(RuntimeError::InvalidArgument { name }) => {\n        eprintln!(\"rejecting bad argument '{name}'; check spelling and format\");\n    }\n    other => other?,\n}","preventionTips":["Validate all runtime arguments (non-empty, correct identifier rules) before calling","Never pass raw user input directly into runtime APIs without sanitizing","Check the changelog when upgrading — argument names/contracts can change"],"tags":["rust","runtime","argument-validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}