BoundaryML/baml · error

Dependency: {} not found

Error message

Dependency: {} not found

What it means

During BAML IR construction, recursively_collect_dependencies walks the dependency graph of a named type via a work-queue over the precomputed shallow-hash map. When a name popped from the queue has no entry in that map (find_dependencies returns None), the walk aborts with 'Dependency: {} not found'. This means a referenced type/class/enum is missing from the intermediate representation.

Source

Thrown at engine/baml-lib/baml-core/src/ir/ir_hasher/mod.rs:97

    pub fields: Arc<Vec<(String, Arc<TypeNonStreaming>)>>,
}

#[derive(Clone)]
pub struct EnumSignatureDetails {
    pub values: Arc<Vec<String>>,
}

fn recursively_collect_dependencies<'a>(
    name: &str,
    shallow_hash: &'a HashMap<&str, ShallowHash>,
    find_dependencies: fn(&str, &'a HashMap<&str, ShallowHash>) -> Option<&'a Vec<String>>,
) -> Result<Vec<&'a String>> {
    // Recursively collect all dependencies
    let mut seen = HashSet::new();
    let mut queue = vec![name];
    while let Some(name) = queue.pop() {
        let dep_hash = find_dependencies(name, shallow_hash)
            .ok_or(anyhow::anyhow!("Dependency: {} not found", name))?;
        for dep in dep_hash {
            // For recursive dependencies, we want to insert self back into the queue
            // This is why seen starts empty, so we actually insert the dependency
            // back into the queue, when/if we see it again
            if seen.insert(dep) {
                queue.push(dep);
            }
        }
    }

    // Sort dependencies so hasher is deterministic
    let mut dependencies = seen.into_iter().collect::<Vec<_>>();
    dependencies.sort();
    Ok(dependencies)
}

impl Signature {
    pub fn display_name(&self) -> &str {

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Search .baml files for the dependency name printed in the error and define the missing class/enum/type
  2. Fix typos in the type reference that points at the missing name
  3. Ensure all .baml files containing the definition are included in the source set passed to the IR builder
  4. Regenerate/clean cached IR artifacts after refactoring type names

Example fix

// before (in .baml)
function Foo() -> MissingType
// after
class MissingType { key string }
function Foo() -> MissingType
Defensive patterns

Strategy: validation

Validate before calling

// before building IR, verify every referenced type exists
fn validate_deps(shallow: &HashMap<&str, ShallowHash>) -> Result<()> {
  for (name, h) in shallow {
    for dep in h.dependencies() {
      if !shallow.contains_key(dep.as_str()) {
        return Err(anyhow!("missing dependency {} referenced by {}", dep, name));
      }
    }
  }
  Ok(())
}

Type guard

fn dependency_exists(name: &str, shallow: &HashMap<&str, ShallowHash>) -> bool {
  shallow.contains_key(name)
}

Prevention

When it happens

Trigger: Calling Ir::new (via ir_hasher::new) when a type's declared dependency string is not a key in the shallow_hash map, e.g. a function/class references a type that was never defined in the .baml sources.

Common situations: Typo in a type reference inside a .baml file; a renamed or deleted class still referenced elsewhere; splitting .baml files and forgetting to include the file defining a dependency; stale generated code referencing removed 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/174f9c47cd3b9aa2. Report an issue: GitHub.