{"record":{"id":"aabe9c789aad9014","repo":"BoundaryML/baml","slug":"recursive-alias-name-not-found","errorCode":null,"errorMessage":"Recursive alias {name} not found","messagePattern":"Recursive alias (.+?) not found","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"engine/baml-lib/jinja-runtime/src/output_format/types.rs","lineNumber":1080,"sourceCode":"}\n\nimpl OutputFormatContent {\n    pub fn find_enum(&self, name: &str) -> Result<&Enum> {\n        self.enums\n            .get(name)\n            .ok_or_else(|| anyhow::anyhow!(\"Enum {name} not found\"))\n    }\n\n    pub fn find_class(&self, mode: &baml_types::StreamingMode, name: &str) -> Result<&Class> {\n        self.classes\n            .get(&(name.to_string(), *mode))\n            .ok_or_else(|| anyhow::anyhow!(\"Class {name} not found\"))\n    }\n\n    pub fn find_recursive_alias_target(&self, name: &str) -> Result<&TypeIR> {\n        self.structural_recursive_aliases\n            .get(name)\n            .ok_or_else(|| anyhow::anyhow!(\"Recursive alias {name} not found\"))\n    }\n}\n\n#[cfg(test)]\nmod tests {\n    use std::vec;\n\n    use baml_types::ir_type::UnionConstructor;\n\n    use super::*;\n\n    #[test]\n    fn render_string() {\n        let content = OutputFormatContent::new_string();\n        let rendered = content.render(RenderOptions::default()).unwrap();\n        assert_eq!(rendered, None);\n    }\n","sourceCodeStart":1062,"sourceCodeEnd":1098,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-lib/jinja-runtime/src/output_format/types.rs#L1062-L1098","documentation":"find_recursive_alias_target resolves a structurally recursive type alias to its TypeIR target from the precomputed structural_recursive_aliases map. The error means an alias name expected to be recursive was not registered in that map. It is an internal resolution failure rather than a user-input parse failure.","triggerScenarios":"Calling find_recursive_alias_target(name) for an alias that is not in structural_recursive_aliases — i.e. the alias either does not exist, is not actually structurally recursive, or the analysis pass that populates the map was skipped/out of date.","commonSituations":"Schema edits that turned a recursive alias into a non-recursive one while code still treats it as recursive; internal resolution ordering bugs; partially regenerated clients mixing old and new type graphs.","solutions":["Confirm the alias actually refers to a structurally recursive type in your .baml schema.","Regenerate/re-analyze the schema so structural_recursive_aliases is rebuilt from the current definitions.","Check that callers only query aliases that passed a recursive-alias check earlier in resolution.","If it occurs during valid resolution, report as a BAML internal bug with the schema snippet."],"exampleFix":"// before: treating non-recursive alias as recursive\nlet t = of.find_recursive_alias_target(\"Tree\")?;\n// after: define a genuinely recursive alias in .baml\n// alias Tree = int | Tree[] | { node: Tree }","handlingStrategy":"type-guard","validationCode":"// only query aliases already classified as structurally recursive\nif !output_format.structural_recursive_aliases.contains_key(alias_name) {\n    // fall back to normal type resolution instead of the recursive path\n}","typeGuard":"fn is_recursive_alias(of: &OutputFormatContent, name: &str) -> bool {\n    of.structural_recursive_aliases.contains_key(name)\n}","tryCatchPattern":"match of.find_recursive_alias_target(name) {\n    Ok(t) => use_target(t),\n    Err(err) => resolve_non_recursive(name).or_else(|_| Err(err)),\n}","preventionTips":["Re-run schema analysis after alias edits","Guard recursive resolution with an is-recursive check","Report persistent failures to BAML maintainers with a minimal schema"],"tags":["rust","schema","alias","type-resolution"],"backgroundTag":"internal-invariant-violation","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"}