{"record":{"id":"c3235a3379bd9fc4","repo":"BoundaryML/baml","slug":"class-name-not-found","errorCode":null,"errorMessage":"Class {name} not found","messagePattern":"Class (.+?) not found","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"engine/baml-lib/jinja-runtime/src/output_format/types.rs","lineNumber":1074,"sourceCode":"        Self::target(TypeIR::List(Box::new(TypeIR::string()), Default::default())).build()\n    }\n\n    pub fn new_string() -> Self {\n        Self::target(TypeIR::string()).build()\n    }\n}\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]","sourceCodeStart":1056,"sourceCodeEnd":1092,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-lib/jinja-runtime/src/output_format/types.rs#L1056-L1092","documentation":"OutputFormatContent::find_class looks up a class by (name, StreamingMode) key; a miss becomes this error. It means a class referenced by the output format, jinja template, or streamed response is not in the BAML schema for that streaming mode. The library throws it rather than returning None so the name appears in the propagated error.","triggerScenarios":"Calling find_class(mode, name) where the classes map has no entry for that (name, mode) pair — e.g. referencing a class in a response before it is defined, or using a streaming-only/non-streaming class in the wrong mode.","commonSituations":"Streaming mode mismatch (a class registered only for streaming or only for non-streaming); renamed class in the schema while old generated clients persist; typo in class name within a prompt template.","solutions":["Verify the class name exists in the .baml schema and matches exactly (case-sensitive).","Regenerate the BAML client after schema edits to sync generated code.","Confirm you pass the correct StreamingMode; check whether the class is only available in streaming or non-streaming form.","Purge cached partial streaming responses keyed to the old schema."],"exampleFix":"// before\nlet c = output_format.find_class(&mode, \"UserExtract\")?;\n// after: ensure class exists in .baml\n// class UserExtract { name string }  ->  baml-cli generate","handlingStrategy":"validation","validationCode":"if !output_format.classes.contains_key(&(class_name.to_string(), mode.clone())) {\n    return Err(anyhow::anyhow!(\"class '{}' unavailable in mode {:?}\", class_name, mode));\n}","typeGuard":"fn class_exists(of: &OutputFormatContent, mode: &StreamingMode, name: &str) -> bool {\n    of.classes.contains_key(&(name.to_string(), mode.clone()))\n}","tryCatchPattern":"match output_format.find_class(&mode, name) {\n    Ok(c) => use_class(c),\n    Err(err) => return Err(err.context(format!(\"check class '{name}' exists in .baml\"))),\n}","preventionTips":["Keep class names in templates in sync with .baml declarations","Verify streaming vs non-streaming availability before lookup","Regenerate generated code after schema renames"],"tags":["rust","schema","class","lookup-failed"],"backgroundTag":"class-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"}