{"record":{"id":"0bd0f84a81e345f1","repo":"BoundaryML/baml","slug":"function-has-no-client","errorCode":null,"errorMessage":"Function {} has no client","messagePattern":"Function (.+?) has no client","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"engine/baml-lib/baml-core/src/ir/walker.rs","lineNumber":118,"sourceCode":"                        (\n                            (),\n                            baml_types::UnresolvedValue::String(\n                                baml_types::StringOr::Value(model.clone()),\n                                (),\n                            ),\n                        ),\n                    )]);\n                    let properties = internal_llm_client::PropertyHandler::<()>::new(options, ());\n                    if let Ok(client) = provider.parse_client_property(properties) {\n                        Ok(client.required_env_vars())\n                    } else {\n                        // We likely can't make a shorthand client from the given provider\n                        Ok(HashSet::new())\n                    }\n                }\n            }\n        } else {\n            anyhow::bail!(\"Function {} has no client\", self.name())\n        }\n    }\n\n    pub fn walk_impls(\n        &'a self,\n    ) -> impl Iterator<Item = Walker<'a, (&'a repr::Function, &'a FunctionConfig)>> {\n        self.elem().configs.iter().map(|c| Walker {\n            ir: self.ir,\n            item: (self.elem(), c),\n        })\n    }\n    pub fn walk_tests(\n        &'a self,\n    ) -> impl Iterator<Item = Walker<'a, (&'a FunctionNode, &'a TestCase)>> {\n        self.elem().tests().iter().map(|i| Walker {\n            ir: self.ir,\n            item: (self.item, i),\n        })","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-lib/baml-core/src/ir/walker.rs#L100-L136","documentation":"The IR walker raises this when a BAML function has no client configured at all, while trying to compute the environment variables the function needs (required_env_vars). Every BAML function must reference a client so the compiler knows which provider/credentials to use.","triggerScenarios":"Calling required_env_vars() on a Walker for a function whose definition omits the `client` field, or whose function block fails to declare any client reference.","commonSituations":"Newly created function blocks where the developer forgot the `client` line; generated functions from templates that omit clients; copying a function body without its client directive.","solutions":["Add a `client <ClientName>` line to the function block in your .baml file","Define a client in a clients block if none exists, then reference it from the function","Re-run generation/validation after adding the client to confirm required env vars resolve"],"exampleFix":"// before\nfunction Summarize(text: string) {\n  prompt #\"...\"#\n}\n// after\nfunction Summarize(text: string) {\n  client Gpt4o\n  prompt #\"...\"#\n}","handlingStrategy":"validation","validationCode":"// Ensure every function has a client before calling required_env_vars\nfor func in &functions {\n    if func.client.is_none() {\n        bail!(\"function {} must declare a client\", func.name);\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never create a function block without a client line","Use templates/snippets that include the client field","Run baml-cli validate on every commit"],"tags":["baml","compile-time","missing-client","config"],"backgroundTag":"missing-required-config-field","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"}