{"record":{"id":"a010c84b40e27088","repo":"BoundaryML/baml","slug":"type-alias-not-found-name","errorCode":null,"errorMessage":"Type alias not found: {name}","messagePattern":"Type alias not found: (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"engine/baml-lib/baml-core/src/ir/repr.rs","lineNumber":145,"sourceCode":"            TypeGeneric::Tuple(type_generics, _) => {\n                type_generics.iter_mut().for_each(|t| self.update_type(t))\n            }\n            TypeGeneric::Arrow(arrow_generic, _) => {\n                self.update_type(&mut arrow_generic.return_type)\n            }\n            TypeGeneric::Union(union_type_generic, _) => union_type_generic\n                .iter_skip_null_mut()\n                .iter_mut()\n                .for_each(|t| self.update_type(t)),\n        }\n    }\n}\n\nimpl TypeLookups for IntermediateRepr {\n    fn expand_recursive_type(&self, name: &str) -> anyhow::Result<&TypeIR> {\n        match self.pass2_repr.resolved_type_aliases.get(name) {\n            Some(ty) => Ok(ty),\n            None => anyhow::bail!(\"Type alias not found: {name}\"),\n        }\n    }\n}\n\n#[derive(Debug)]\npub struct TopLevelAssignment {\n    pub name: Node<String>,\n    pub expr: Node<Expr<ExprMetadata>>,\n}\n\n#[derive(Clone, Debug)]\npub struct ClassConstructor {\n    pub class_name: Node<String>,\n    pub fields: Vec<Node<ClassConstructorField>>,\n}\n\n#[derive(Clone, Debug)]\npub enum ClassConstructorField {","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-lib/baml-core/src/ir/repr.rs#L127-L163","documentation":"During IR construction, recursive/named type references must be expanded by looking up the alias in the resolved type alias table. If the name is absent from resolved_type_aliases, BAML bails with this error. It means a type reference points to an alias that was never defined or never resolved.","triggerScenarios":"expand_recursive_type(name) called via TypeLookups for IntermediateRepr when the referenced type alias (e.g. from a recursive type definition like `type Foo = Bar[] & Foo` or an alias referencing itself/another alias) is not present in the resolved alias map.","commonSituations":"Typo in a type alias name; referencing an alias defined in another BAML file not included in the source; recursive type cycles that failed earlier resolution; renamed alias while old references remain.","solutions":["Check the alias name in the error against your .baml type alias definitions for typos.","Ensure the file defining the alias is part of the BAML source loaded by the generator.","Fix recursive/circular alias definitions so every referenced alias actually resolves.","Run baml CLI generate to see full diagnostics of unresolved types."],"exampleFix":"// before\ntype UserList = Users[]\n// after\ntype UserList = User[]","handlingStrategy":"validation","validationCode":"# pseudo-check over .baml sources before compiling:\n# collect all 'type X = ...' aliases, then verify every referenced alias exists\nimport re\naliases = set(re.findall(r'^\\s*type\\s+(\\w+)\\s*=', src, re.M))\nrefs = set(re.findall(r'\\b([A-Z]\\w+)\\b', src))\nunresolved = refs - aliases - PRIMITIVES  # e.g. {\"string\",\"int\",\"float\",\"bool\"}","typeGuard":null,"tryCatchPattern":"match ir.expand_recursive_type(name) {\n    Ok(ty) => ty,\n    Err(e) if e.to_string().starts_with(\"Type alias not found\") => {\n        eprintln!(\"define or fix alias '{name}' before generating\");\n        std::process::exit(1);\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Keep alias names consistent and case-correct across .baml files.","Include every .baml file defining referenced types in the generator globs.","Regenerate with the BAML CLI after any type renames."],"tags":["baml","types","schema","alias"],"backgroundTag":"resource-not-found","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"}