{"record":{"id":"828da57858b66bfb","repo":"BoundaryML/baml","slug":"function-function-name-not-found","errorCode":null,"errorMessage":"function `{function_name}` not found","messagePattern":"function `(.+?)` not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_cli/src/run_command.rs","lineNumber":570,"sourceCode":"                    target,\n                    &project_root,\n                ));\n            };\n\n        // Patch `argv[1]` to the engine-canonical display name (strips\n        // `user.` prefix) so scripts and the direct path agree.\n        if let Some(info) = engine.find_user_function(&function_name) {\n            let display = info.display_name.clone();\n            let mut patched: Vec<String> = engine.argv().to_vec();\n            if patched.len() >= 2 && (was_script || display != *target) {\n                patched[1] = display;\n                engine.set_argv(patched);\n            }\n        }\n\n        let func_info = engine\n            .find_user_function(&function_name)\n            .ok_or_else(|| anyhow!(\"function `{function_name}` not found\"))?;\n        baml_exec::validate_help_param(&engine, &function_name)?;\n\n        let target_is_typed = !func_info.param_names.is_empty();\n        let parsed = if target_is_typed {\n            let display = function_name\n                .strip_prefix(\"user.\")\n                .unwrap_or(&function_name);\n            let bin_name = format!(\"baml run {display} --\");\n            match baml_exec::parse_target_argv(\n                &bin_name,\n                &function_name,\n                &func_info,\n                &effective_target_args,\n            ) {\n                Ok(p) => p,\n                Err(err) => return surface_clap_error(reporter, err),\n            }\n        } else {","sourceCodeStart":552,"sourceCodeEnd":588,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_cli/src/run_command.rs#L552-L588","documentation":"Runtime lookup failure in `baml run`: the target named on the command line (or via a script's --function) does not match any function declared in the loaded BAML project. The engine's find_user_function returned nothing before execution could start — the name may be misspelled, missing the user. prefix convention, or defined in a file outside the project root.","triggerScenarios":"`run_single_target` calls `engine.find_user_function(&function_name)` and receives None — the name came from `--function`/`-f` or a script expansion.","commonSituations":"Typo in the function name; the function exists in a different `.baml` file not included in the project; prefixing mistakes (functions are qualified like `user.<name>`); a script in `baml.toml` referencing a deleted function.","solutions":["Check the function name spelling and that it exists in the loaded `.baml` sources","List available functions and pick the correct one","Ensure the file defining the function is inside the project root so it is compiled"],"exampleFix":"// before\nbaml run --file baml_src/main.baml -f MyFuntion\n// after\nbaml run --file baml_src/main.baml -f MyFunction","handlingStrategy":"validation","validationCode":"const fns = engine.user_functions().map(f => f.qualified_name.replace(/^user\\./, '')); if (!fns.includes(name)) throw new Error(`function '${name}' not found; available: ${fns.join(', ')}`);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify function names against the .baml sources before running","Keep baml.toml scripts in sync with renamed/deleted functions","Run from a project root that includes the file defining the function"],"tags":["cli","not-found","function","baml"],"backgroundTag":"entity-not-found","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"}