BoundaryML/baml · error

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

Error message

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

What it means

Multi-suggestion arm of error_not_found!: the entity was not found and sort_by_match produced two or more (up to 5) close candidates, so the error lists them: 'TYPE `NAME` not found. Did you mean one of: A, B, C?'.

Source

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

#[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
                )
            }
        }
    }};
}

#[macro_export]
macro_rules! error_unsupported {
    ($type:expr, $name:expr, $reason:expr) => {
        anyhow::bail!("Unsupported {} `{}`: {}", $type, $name, $reason)
    };
}

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Pick the correct symbol from the suggested list and use its exact name
  2. Use the fully qualified/unique name if several candidates share a prefix
  3. Define the missing entity if none of the suggestions is what you meant

Example fix

// before
function A() -> Podcst
// error: ... Did you mean one of: Podcast, Podcasts, PodcastSh?
// after
function A() -> Podcast
Defensive patterns

Strategy: validation

Validate before calling

if !symbols.contains(name) {
  let suggestions = top_matches(name, symbols, 5);
  eprintln!("{} not found; candidates: {:?}", name, suggestions);
}

Type guard

fn resolve_unique<'a>(name: &str, syms: &'a [String]) -> Option<&'a str> {
  let m: Vec<&str> = syms.iter().map(|s| s.as_str()).filter(|s| *s == name).collect();
  if m.len() == 1 { Some(m[0]) } else { None }
}

Try / catch

match Err(e) if e.to_string().contains("Did you mean one of:") => {
  // choose among listed candidates
}

Prevention

When it happens

Trigger: IR lookup via error_not_found! when the bad name has multiple fuzzy matches among candidates, e.g. several similarly named classes/enums/functions.

Common situations: Ambiguous short names (e.g. 'Test' matching TestA/TestB); referencing by partial name expecting prefix matching; families of similarly named generated types.

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/3c1a061f02ecadcf. Report an issue: GitHub.