{"record":{"id":"d8421621bf1cd41d","repo":"BoundaryML/baml","slug":"function-name-not-found-did-you-mean-one-of","errorCode":null,"errorMessage":"function `{name}` not found. Did you mean one of:\n{}","messagePattern":"function `(.+?)` not found\\. Did you mean one of:\n(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_cli/src/run_command.rs","lineNumber":1349,"sourceCode":"        candidates.sort();\n        candidates.dedup();\n\n        let suggestions: Vec<&str> = candidates\n            .iter()\n            .filter(|c| {\n                c.contains(name) || name.contains(c.as_str()) || strsim::jaro_winkler(c, name) > 0.7\n            })\n            .take(5)\n            .map(String::as_str)\n            .collect();\n\n        if suggestions.is_empty() {\n            anyhow!(\n                \"function `{name}` not found.\\n\\\n                 use `baml run --list` to see available targets.\"\n            )\n        } else {\n            anyhow!(\n                \"function `{name}` not found. Did you mean one of:\\n{}\",\n                suggestions\n                    .iter()\n                    .map(|s| format!(\"  - {s}\"))\n                    .collect::<Vec<_>>()\n                    .join(\"\\n\")\n            )\n        }\n    }\n\n    fn target_not_found_error_in(\n        scripts: &HashMap<String, Vec<String>>,\n        engine: &BexEngine,\n        name: &str,\n        cwd: &Path,\n    ) -> anyhow::Error {\n        let namespaces = collect_namespaces(engine);\n        struct Candidate {","sourceCodeStart":1331,"sourceCodeEnd":1367,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_cli/src/run_command.rs#L1331-L1367","documentation":"The did-you-mean variant of the `--function` not-found error: `baml run --function <name>` was given a name that matches no user function, but the CLI found up to 5 close candidates (substring match either way, or Jaro-Winkler similarity > 0.7) among the compiled program's user functions. The error lists those suggestions; scripts and namespaces are deliberately excluded because they aren't reachable via `--function`.","triggerScenarios":"Running `baml run --function <name>` where `<name>` is a near-miss of an actual user function name — close enough to trigger the suggestion heuristic but not an exact match (e.g. different casing, plural/singular, truncated name).","commonSituations":"Typos and casing mistakes (camelCase vs snake_case); an older name kept in muscle memory after a rename; autocomplete truncation in shell history; referencing a function that exists in another version of the codebase.","solutions":["Re-run with one of the suggested names listed in the error (e.g. `baml run --function <suggested>`).","Copy the exact function name from `baml run --list` output.","If the intended function was renamed, update the calling script/CI config to the new name.","Confirm you are in the right project so the intended function is compiled."],"exampleFix":"// before\nbaml run --function classifySentament\n// after\nbaml run --function classifySentiment","handlingStrategy":"validation","validationCode":"// shell: exact-match check before running\nbaml run --list | grep -qx \"$FUNC_NAME\" || { echo \"typo? check list below\"; baml run --list; exit 1; }","typeGuard":null,"tryCatchPattern":"// parse the 'Did you mean' suggestions from stderr\nout=$(baml run --function \"$FUNC\" 2>&1) || { echo \"$out\"; exit 1; }","preventionTips":["Adopt a consistent naming convention (e.g. camelCase) and enforce it.","Use shell completion generated from `baml run --list`.","When renaming functions, grep scripts and CI configs for old names."],"tags":["cli","command-line","function-not-found","typo","baml"],"backgroundTag":"command-not-found","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}