{"record":{"id":"6f565acd0db4fafd","repo":"BoundaryML/baml","slug":"error-while-calling-function-name","errorCode":null,"errorMessage":"error while calling {function_name}","messagePattern":"error while calling (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"engine/language_client_ruby/ext/ruby_ffi/src/lib.rs","lineNumber":148,"sourceCode":"\n        let mut collectors = Vec::new();\n        for i in collector.into_iter() {\n            collectors.push(<&Collector>::try_convert(i)?.inner.clone());\n        }\n\n        let retval = match rb_self.t.block_on(rb_self.inner.call_function(\n            function_name.clone(),\n            &args,\n            &ctx.inner,\n            type_registry.map(|t| &t.inner),\n            client_registry.map(|c| c.inner.borrow_mut()).as_deref(),\n            Some(collectors),\n            env_vars,\n            None,\n            TripWire::new(None),\n        )) {\n            (Ok(res), _) => Ok(FunctionResult::new(res)),\n            (Err(e), _) => Err(Error::new(\n                ruby.exception_runtime_error(),\n                format!(\n                    \"{:?}\",\n                    e.context(format!(\"error while calling {function_name}\"))\n                ),\n            )),\n        };\n\n        retval\n    }\n\n    fn stream_function(\n        ruby: &Ruby,\n        rb_self: &BamlRuntimeFfi,\n        function_name: String,\n        args: RHash,\n        ctx: &RuntimeContextManager,\n        type_registry: Option<&types::type_builder::TypeBuilder>,","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_ruby/ext/ruby_ffi/src/lib.rs#L130-L166","documentation":"Raised when the BAML runtime itself fails while executing a function invoked via call_function. The specific underlying failure (client config, prompt rendering, provider error, parsing) is attached via anyhow context and printed with {:?} after the message.","triggerScenarios":"baml_runtime.call_function(...) returns Err for any reason: unknown function name, misconfigured LLM client, missing API key in env_vars, provider HTTP failure, or output-parsing failure.","commonSituations":"Calling a function name that doesn't exist in the .baml files; missing OPENAI_API_KEY/ANTHROPIC_API_KEY; wrong model name in client config; network failures or provider rate limits.","solutions":["Read the {:?} detail for the exact underlying cause.","Verify the function name exists in your .baml files (or reload the runtime after edits).","Check required API keys are present in the env_vars passed to the runtime/call.","Test the function in the BAML playground / CLI to reproduce outside Ruby.","Wrap the call in begin/rescue and inspect the message to distinguish config vs provider errors."],"exampleFix":"// before\nres = Baml.call_function('ExtractResume', args, ctx, {}) # missing API key env\n// after\nres = Baml.call_function('ExtractResume', args, ctx, ENV.to_h.merge('OPENAI_API_KEY' => api_key))","handlingStrategy":"try-catch","validationCode":"raise ArgumentError, \"function '#{fn}' not found\" unless File.read(baml_files.join).scan(/function\\s+#{fn}\\b/).any?","typeGuard":null,"tryCatchPattern":"begin\n  res = Baml.call_function(fn, args, ctx, ENV.to_h)\nrescue RuntimeError => e\n  logger.error(\"BAML call_function failed for #{fn}: #{e.message}\")\n  raise\nend","preventionTips":["Confirm function names against your .baml sources before calling.","Pass required provider API keys via env_vars (ENV.to_h or explicit merge).","Validate client/model config with the BAML CLI or playground.","Add retry-with-backoff for transient provider errors at a higher level."],"tags":["llm","runtime","baml","ruby"],"backgroundTag":"api-request-failed","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}