BoundaryML/baml · error · anyhow::Error
Field type uses unresolvable local identifier {}
Error message
Field type uses unresolvable local identifier {} What it means
When resolving a field's type in the IR, a local identifier used as a type must resolve to a known walker/walker-resolved type. If the identifier (e.g. a field type name) cannot be resolved in scope, BAML returns this error. It indicates a type reference in a class/field definition that points to nothing in the schema.
Source
Thrown at engine/baml-lib/baml-core/src/ir/repr.rs:1950
_ => base_type,
}
}
Some(TypeWalker::TypeAlias(alias_walker)) => {
if db.is_recursive_type_alias(&alias_walker.id) {
let resolved = alias_walker.resolved();
// TODO: use resolved in some way
TypeIR::RecursiveTypeAlias {
name: alias_walker.name().to_string(),
mode: StreamingMode::Streaming,
meta: Default::default(),
}
} else {
alias_walker.resolved().to_owned().repr(db)?
}
}
None => {
return Err(anyhow!(
"Field type uses unresolvable local identifier {}",
idn
))
}
},
arity,
),
ast::FieldType::List(arity, ft, dims, ..) => {
// NB: potential bug: this hands back a 1D list when dims == 0
let mut repr = TypeIR::List(Box::new(ft.repr(db)?), Default::default());
for _ in 1u32..*dims {
repr = TypeIR::list(repr);
}
if arity.is_optional() {
repr = TypeIR::optional(repr);
}View on GitHub (pinned to bd85ce9dee)
Solutions
- Check the identifier in the message against your defined classes/enums/type aliases.
- Fix casing and spelling — BAML type names are case-sensitive.
- Ensure the file defining the referenced type is included in the generator's source globs.
- Run baml CLI generate to list all unresolved type references at once.
Example fix
// before
class Order {
buyer Usr
}
// after
class Order {
buyer User
} Defensive patterns
Strategy: validation
Validate before calling
# verify class field type names resolve to defined types
import re
defined = set(re.findall(r'^\s*(?:class|enum)\s+(\w+)', src, re.M))
defined |= set(re.findall(r'^\s*type\s+(\w+)\s*=', src, re.M))
defined |= {"string", "int", "float", "bool", "map", "string[]"}
for cls in re.finditer(r'class\s+\w+\s*\{(.*?)\}', src, re.S):
for ftype in re.findall(r'^\s*\w+\s+([A-Z]\w*)', cls.group(1), re.M):
if ftype not in defined:
print(f"unresolved field type: {ftype}") Try / catch
match ast_field_type.repr(db) {
Ok(t) => t,
Err(e) if e.to_string().contains("unresolvable local identifier") => {
eprintln!("define or correctly spell the referenced type before generating");
return Err(e);
}
Err(e) => return Err(e),
} Prevention
- Double-check spelling/casing of type names in class fields.
- Ensure all .baml files defining referenced types are loaded.
- Search-and-replace old type names after renames.
When it happens
Trigger: repr(db) on a field type containing an identifier (idn) with no matching resolution in the local scope — i.e. a class field typed with a name that is not a defined class, enum, alias, or primitive in the BAML schema.
Common situations: Typo in a class field's type name; referencing a class/enum defined in another .baml file not loaded; deleting/renaming a type while fields still reference it; case-sensitivity mistakes (user vs User).
Related errors
- Type alias not found: {name}
- Expression functions must have a return type
- Expression functions must have return type.
- Type mismatch: {message}
- Schema inconsistency: {message}
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/325656b8c1c9535a.
Report an issue: GitHub.