BoundaryML/baml · error

{} `{}` not found. Did you mean: {}?

Error message

{} `{}` not found. Did you mean: {}?

What it means

Single-suggestion arm of error_not_found!: the referenced entity was not found, but sort_by_match found exactly one close candidate. The full message is 'TYPE `NAME` not found. Did you mean: CANDIDATE?' telling the developer the likely intended symbol.

Source

Thrown at engine/baml-lib/baml-core/src/ir/ir_helpers/error_utils.rs:61

        .filter(|&&(dist, _)| dist <= THRESHOLD)
        .map(|&(_, idx)| options.index(idx).as_ref());

    // Return either a limited or full set of filtered names
    match max_return {
        Some(max) => filtered_names.take(max).collect(),
        None => filtered_names.collect(),
    }
}

#[macro_export]
macro_rules! error_not_found {
    ($type:expr, $name:expr, $candidates:expr) => {{
        let suggestions =
            $crate::ir::ir_helpers::error_utils::sort_by_match($name, $candidates, Some(5));
        match suggestions.len() {
            0 => anyhow::bail!("{} `{}` not found.", $type, $name),
            1 => {
                anyhow::bail!(
                    "{} `{}` not found. Did you mean: {}?",
                    $type,
                    $name,
                    suggestions[0]
                )
            }
            _ => {
                let suggestions = suggestions.join(", ");
                anyhow::bail!(
                    "{} `{}` not found. Did you mean one of: {}?",
                    $type,
                    $name,
                    suggestions
                )
            }
        }
    }};
}

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Use the suggested name from the error message in your .baml file
  2. Rename the definition if the intended symbol was renamed
  3. Verify the referenced symbol exists with the exact spelling

Example fix

// before
function A() -> userr
// error: class `userr` not found. Did you mean: User?
// after
function A() -> User
Defensive patterns

Strategy: validation

Validate before calling

if !symbols.contains(name) {
  let best = closest_match(name, symbols);
  eprintln!("{} not found; did you mean {:?}?", name, best);
}

Type guard

fn exact_or_suggestion<'a>(name: &str, syms: &'a [String]) -> Option<&'a str> {
  syms.iter().find(|s| s.as_str() == name).map(|s| s.as_str())
}

Try / catch

match Err(e) if e.to_string().contains("Did you mean:") => {
  // apply the suggested name from the message
}

Prevention

When it happens

Trigger: IR lookup via error_not_found! where the misspelled name has exactly one fuzzy match among the candidate definitions (similarity above cutoff, others below).

Common situations: Small typos like wrong capitalization or a singular/plural mismatch (e.g. 'User' vs 'Users'); autocomplete picking a stale name after a rename.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12). Data as JSON: /api/errors/0e43d7e2f8b4c757. Report an issue: GitHub.