{"record":{"id":"325656b8c1c9535a","repo":"BoundaryML/baml","slug":"field-type-uses-unresolvable-local-identifier","errorCode":null,"errorMessage":"Field type uses unresolvable local identifier {}","messagePattern":"Field type uses unresolvable local identifier (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"engine/baml-lib/baml-core/src/ir/repr.rs","lineNumber":1950,"sourceCode":"                            _ => base_type,\n                        }\n                    }\n                    Some(TypeWalker::TypeAlias(alias_walker)) => {\n                        if db.is_recursive_type_alias(&alias_walker.id) {\n                            let resolved = alias_walker.resolved();\n                            // TODO: use resolved in some way\n                            TypeIR::RecursiveTypeAlias {\n                                name: alias_walker.name().to_string(),\n                                mode: StreamingMode::Streaming,\n                                meta: Default::default(),\n                            }\n                        } else {\n                            alias_walker.resolved().to_owned().repr(db)?\n                        }\n                    }\n\n                    None => {\n                        return Err(anyhow!(\n                            \"Field type uses unresolvable local identifier {}\",\n                            idn\n                        ))\n                    }\n                },\n                arity,\n            ),\n            ast::FieldType::List(arity, ft, dims, ..) => {\n                // NB: potential bug: this hands back a 1D list when dims == 0\n                let mut repr = TypeIR::List(Box::new(ft.repr(db)?), Default::default());\n\n                for _ in 1u32..*dims {\n                    repr = TypeIR::list(repr);\n                }\n\n                if arity.is_optional() {\n                    repr = TypeIR::optional(repr);\n                }","sourceCodeStart":1932,"sourceCodeEnd":1968,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-lib/baml-core/src/ir/repr.rs#L1932-L1968","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","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."],"exampleFix":"// before\nclass Order {\n  buyer Usr\n}\n// after\nclass Order {\n  buyer User\n}","handlingStrategy":"validation","validationCode":"# verify class field type names resolve to defined types\nimport re\ndefined = set(re.findall(r'^\\s*(?:class|enum)\\s+(\\w+)', src, re.M))\ndefined |= set(re.findall(r'^\\s*type\\s+(\\w+)\\s*=', src, re.M))\ndefined |= {\"string\", \"int\", \"float\", \"bool\", \"map\", \"string[]\"}\nfor cls in re.finditer(r'class\\s+\\w+\\s*\\{(.*?)\\}', src, re.S):\n    for ftype in re.findall(r'^\\s*\\w+\\s+([A-Z]\\w*)', cls.group(1), re.M):\n        if ftype not in defined:\n            print(f\"unresolved field type: {ftype}\")","typeGuard":null,"tryCatchPattern":"match ast_field_type.repr(db) {\n    Ok(t) => t,\n    Err(e) if e.to_string().contains(\"unresolvable local identifier\") => {\n        eprintln!(\"define or correctly spell the referenced type before generating\");\n        return Err(e);\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["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."],"tags":["baml","types","schema","unresolved"],"backgroundTag":"invalid-identifier","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}