{"record":{"id":"4c1a5aa99ce59e72","repo":"BoundaryML/baml","slug":"error-while-building-http-request-for-function-function-name","errorCode":null,"errorMessage":"error while building HTTP request for function {function_name}","messagePattern":"error while building HTTP request for function (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"engine/language_client_ruby/ext/ruby_ffi/src/lib.rs","lineNumber":246,"sourceCode":"                    format!(\"error while parsing call_function args:\\n{e}\"),\n                ));\n            }\n        };\n\n        rb_self\n            .inner\n            .build_request_sync(\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                stream,\n                env_vars,\n            )\n            .map(HTTPRequest::from)\n            .map_err(|e| {\n                Error::new(\n                    ruby.exception_runtime_error(),\n                    format!(\n                        \"{:?}\",\n                        e.context(format!(\n                            \"error while building HTTP request for function {function_name}\"\n                        ))\n                    ),\n                )\n            })\n    }\n\n    pub fn parse_llm_response(\n        ruby: &Ruby,\n        rb_self: &BamlRuntimeFfi,\n        function_name: String,\n        llm_response: String,\n        types: RModule,\n        partial_types: RModule,","sourceCodeStart":228,"sourceCodeEnd":264,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_ruby/ext/ruby_ffi/src/lib.rs#L228-L264","documentation":"Raised when the BAML runtime fails to render/build the HTTP request for a function via build_request. The anyhow context attaches the precise cause — prompt rendering failure, missing client or resolver mismatch, invalid client config — formatted with {:?} in the RuntimeError.","triggerScenarios":"baml_runtime.build_request(...) returns Err: the function or its client cannot be resolved, prompt templates fail to render with the given args/ctx, or client_registry/client lookup fails.","commonSituations":"Referencing a named client that isn't defined in the .baml files; passing a client_registry that doesn't match; prompt template referencing parameters absent from args; dynamic client registry built incorrectly in Ruby.","solutions":["Read the {:?} detail for the exact rendering or client-resolution error.","Verify the function's client is defined (or the client_registry passed contains it).","Confirm all prompt-template parameters are supplied in args.","Render-test the function in the BAML playground to validate the prompt compiles."],"exampleFix":"// before\nreq = Baml.build_request('MyFn', args, ctx, ENV, false) # client 'gpt-4-turbo' not defined\n// after\n# define client \"gpt-4-turbo\" in .baml or pass a registry containing it\nreq = Baml.build_request('MyFn', args, ctx, ENV, false)","handlingStrategy":"validation","validationCode":"raise ArgumentError, \"client registry must be a Hash of Baml::Client strings\" if client_registry && !client_registry.is_a?(Hash)","typeGuard":null,"tryCatchPattern":"begin\n  req = Baml.build_request(fn, args, ctx, ENV.to_h, stream)\nrescue RuntimeError => e\n  if e.message.include?('error while building HTTP request')\n    logger.error(\"Request build failed for #{fn}: #{e.message}\")\n  end\n  raise\nend","preventionTips":["Define every client referenced by the function in your .baml files.","Ensure args supply all parameters used by the prompt template.","Validate prompt rendering in the BAML playground before shipping.","Keep client_registry contents consistent with compiled .baml definitions."],"tags":["http","prompt","baml","ruby"],"backgroundTag":"http-request-failed","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}