{"record":{"id":"016436daae767a97","repo":"BoundaryML/baml","slug":"not-found","errorCode":null,"errorMessage":"{} `{}` not found.","messagePattern":"(.+?) `(.+?)` not found\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-lib/baml-core/src/ir/ir_helpers/error_utils.rs","lineNumber":59,"sourceCode":"    let filtered_names = name_distances\n        .iter()\n        .filter(|&&(dist, _)| dist <= THRESHOLD)\n        .map(|&(_, idx)| options.index(idx).as_ref());\n\n    // Return either a limited or full set of filtered names\n    match max_return {\n        Some(max) => filtered_names.take(max).collect(),\n        None => filtered_names.collect(),\n    }\n}\n\n#[macro_export]\nmacro_rules! error_not_found {\n    ($type:expr, $name:expr, $candidates:expr) => {{\n        let suggestions =\n            $crate::ir::ir_helpers::error_utils::sort_by_match($name, $candidates, Some(5));\n        match suggestions.len() {\n            0 => anyhow::bail!(\"{} `{}` not found.\", $type, $name),\n            1 => {\n                anyhow::bail!(\n                    \"{} `{}` not found. Did you mean: {}?\",\n                    $type,\n                    $name,\n                    suggestions[0]\n                )\n            }\n            _ => {\n                let suggestions = suggestions.join(\", \");\n                anyhow::bail!(\n                    \"{} `{}` not found. Did you mean one of: {}?\",\n                    $type,\n                    $name,\n                    suggestions\n                )\n            }\n        }","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-lib/baml-core/src/ir/ir_helpers/error_utils.rs#L41-L77","documentation":"This is the zero-suggestions arm of the error_not_found! macro: a named entity (class, enum, function, etc.) was looked up in the IR and not found, and no near-match candidates existed to suggest. The error states 'TYPE `NAME` not found.' with no 'did you mean' hint.","triggerScenarios":"Invoking error_not_found!(\"class\", \"Foo\", candidates) from IR resolution when 'Foo' matches no definition and no candidate passes the similarity cutoff in sort_by_match.","commonSituations":"Completely mistyped type/function names in .baml; referencing a type after deleting its definition; working in a repo where the .baml defining the symbol was never committed.","solutions":["Define the missing entity in a .baml file","Fix the name to exactly match an existing definition (names are case-sensitive)","Check that the file defining the entity is in the baml_src directory","Run a listing of available classes/enums/functions to pick the right name"],"exampleFix":"// before\nfunction A() -> UserProfil\n// after\nclass UserProfile { id int }\nfunction A() -> UserProfile","handlingStrategy":"validation","validationCode":"// verify the symbol exists before referencing it\n// baml CLI: list available definitions\n// bazel-like check in Rust caller:\nif ir.find_class(name).is_err() && ir.find_enum(name).is_err() {\n  eprintln!(\"{} is not defined in any .baml file\", name);\n}","typeGuard":"fn symbol_exists(name: &str, ir: &Ir) -> bool {\n  ir.find_class(name).is_ok() || ir.find_enum(name).is_ok() || ir.find_function(name).is_ok()\n}","tryCatchPattern":"match result {\n  Err(e) if e.to_string().contains(\"not found.\") => {\n    // no suggestions: name is completely unknown, fix definition or spelling\n    Err(e)\n  }\n  other => other,\n}","preventionTips":["Copy symbol names from definitions, not from memory","Keep one canonical .baml source directory","Use editor BAML extension for autocomplete"],"tags":["baml","ir","not-found","macro"],"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-14T05:17:10.506Z"}