{"record":{"id":"acdb2905e0e0dbe5","repo":"BoundaryML/baml","slug":"this-config-does-not-have-any-returns-declared-at-least-one","errorCode":null,"errorMessage":"This config does not have any returns declared! At least one return in one match path is required.","messagePattern":"This config does not have any returns declared! At least one return in one match path is required\\.","errorType":"validation","errorClass":"UDFConfigError","httpStatus":null,"severity":"error","filePath":"engine/boundary-udf/src/config.rs","lineNumber":74,"sourceCode":"/// Raw Jinja template which will be executed for the inputs that match.\n#[derive(Debug, Deserialize, Serialize, Clone)]\n#[serde(transparent)]\npub struct OutputExpression(pub String);\n\n#[derive(Debug, Deserialize, Serialize)]\npub struct UDFConfig {\n    pub version: String,\n    pub name: String,\n    pub description: String,\n    #[serde(rename = \"constants\")]\n    #[serde(default)]\n    pub global_constants: BamlMap<String, Constant>,\n    pub functions: Vec<Function>,\n}\n\n#[derive(Debug, Error)]\npub enum UDFConfigError {\n    #[error(\"This config does not have any returns declared! At least one return in one match path is required.\")]\n    NoReturnsDeclared,\n}\n\nimpl UDFConfig {\n    /// Verifies that the configuration is valid beyond deserialization format.\n    /// Checked invariants:\n    /// - At least one return is declared in the configuration: `gather_all_outputs` will return a\n    ///   non-empty set.\n    pub fn check(&self) -> Result<(), UDFConfigError> {\n        fn find_returns(overrides: &[Function]) -> bool {\n            for ov in overrides {\n                if !ov.returns.is_empty() {\n                    return true;\n                }\n            }\n\n            overrides.iter().any(|f| find_returns(&f.overrides))\n        }","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/boundary-udf/src/config.rs#L56-L92","documentation":"UDFConfig::validate enforces that the declared functions collectively declare at least one return across their match paths. A config whose functions have no returns anywhere cannot produce results, so validation fails with the NoReturnsDeclared variant carrying this message.","triggerScenarios":"Deserializing a UDF config whose `functions` array is empty, or whose function definitions contain only match paths with no `return` clauses, then calling the validation method on UDFConfig.","commonSituations":"Hand-editing or generating boundary-udf JSON configs and omitting the returns section; a template/scaffold that created function skeletons without returns being validated as-is.","solutions":["Add at least one return clause to one match path of at least one function in the config","If the file is a work in progress, finish defining a return before validating/deploying the config","If no functions are needed, remove the empty functions array or skip validation for placeholder configs"],"exampleFix":"// before\n{ \"functions\": [{ \"name\": \"f\", \"match\": [{ \"when\": true }] }] }\n// after\n{ \"functions\": [{ \"name\": \"f\", \"match\": [{ \"when\": true, \"return\": \"ok\" }] }] }","handlingStrategy":"validation","validationCode":"const cfg = JSON.parse(configJson);\nconst hasReturn = cfg.functions?.some(f =>\n  (f.match ?? []).some(path => path.return !== undefined));\nif (!hasReturn) throw new Error(\"config must declare at least one return in a match path\");","typeGuard":null,"tryCatchPattern":"match config.validate() { Ok(_) => ..., Err(UDFConfigError::NoReturnsDeclared) => eprintln!(\"add a return to at least one match path\") }","preventionTips":["Validate configs in CI before deployment","Use a JSON schema that requires 'return' on at least one match path","Never deploy scaffolded function skeletons without returns"],"tags":["config","validation","udf"],"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-14T11:17:12.474Z"}