{"record":{"id":"85e74ea4c6694241","repo":"BoundaryML/baml","slug":"property-not-found-in-class","errorCode":null,"errorMessage":"Property not found: {} in class {}","messagePattern":"Property not found: (.+?) in class (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_cffi/src/raw_ptr_wrapper/type_builder/objects.rs","lineNumber":356,"sourceCode":"        prop.lock().unwrap().set_type(field_type);\n        Ok(self.create_property(name, rt))\n    }\n\n    pub fn property(&self, rt: &BamlRuntime, name: &str) -> anyhow::Result<ClassPropertyBuilder> {\n        self.mode.at_least(NodeRW::ReadOnly)?;\n        let cls = self.cls(rt)?;\n\n        let builder = cls.lock().unwrap();\n        match builder.maybe_get_property(name) {\n            Some(_) => Ok(self.create_property(name, rt)),\n            None => {\n                // if the IR has the property, then its valid to add it again\n                if let Ok(cls) = rt.ir.find_class(self.class_name.as_str()) {\n                    if cls.find_field(name).is_some() {\n                        let _ = builder.upsert_property(name);\n                        Ok(self.create_property(name, rt))\n                    } else {\n                        anyhow::bail!(\"Property not found: {} in class {}\", name, self.class_name)\n                    }\n                } else {\n                    anyhow::bail!(\"Property not found: {} in class {}\", name, self.class_name)\n                }\n            }\n        }\n    }\n\n    pub fn is_from_ast(&self, rt: &BamlRuntime) -> anyhow::Result<bool> {\n        self.mode.at_least(NodeRW::ReadOnly)?;\n        Ok(rt.ir.find_class(self.class_name.as_str()).is_ok())\n    }\n}\n\n#[derive(Debug, Clone)]\npub struct ClassPropertyBuilder {\n    type_builder: RuntimeTypeBuilder,\n    class_name: String,","sourceCodeStart":338,"sourceCodeEnd":374,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_cffi/src/raw_ptr_wrapper/type_builder/objects.rs#L338-L374","documentation":"ClassBuilder::property looks up an existing property to modify. If the property is not present in the IR's class definition (find_field returns None) and not otherwise resolvable, it bails with 'Property not found'. Only properties that already exist can be retrieved this way; new ones must be added with add_property.","triggerScenarios":"Calling cb.property(rt, \"field\") for a property name that the class does not define, whether from a typo or because the property was never added.","commonSituations":"Typo in property name; calling .property() before add_property(); the property was removed/renamed in the BAML source while builder code still references the old name.","solutions":["Add the property first with cb.add_property(rt, name, type) before lookup","Verify the exact property name against the class definition (case-sensitive)","Use list_properties to confirm the field exists before lookup"],"exampleFix":"// before\nlet p = cb.property(rt, \"nmae\")?; // typo -> not found\n// after\nlet p = match cb.property(rt, \"name\") {\n    Ok(p) => p,\n    Err(_) => cb.add_property(rt, \"name\", tb.string_type())?,\n};","handlingStrategy":"try-catch","validationCode":"# check before lookup\nif \"name\" not in cb.list_properties(rt):\n    cb.add_property(rt, \"name\", tb.string())","typeGuard":null,"tryCatchPattern":"try:\n    p = cb.property(rt, name)\nexcept Exception as e:\n    if \"not found\" in str(e):\n        cb.add_property(rt, name, ty)\n        p = cb.property(rt, name)\n    else:\n        raise","preventionTips":["Verify property names with list_properties before lookup","Call add_property for new fields instead of property()","Track BAML source renames and update builder code accordingly"],"tags":["type-builder","property","not-found","class"],"backgroundTag":"property-not-found","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}