{"record":{"id":"5ab8fa17479d4ca6","repo":"BoundaryML/baml","slug":"getattr-checked","errorCode":null,"errorMessage":"getattr(Checked)","messagePattern":"getattr\\(Checked\\)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"engine/language_client_python/src/types/function_results.rs","lineNumber":326,"sourceCode":"    let literal = typing.getattr(\"Literal\").expect(\"Literal\");\n\n    let value_with_possible_checks = if !checks.is_empty() {\n        // Generate the Python checks\n        let python_checks = pythonize_checks(py, cls_module, &checks, model_validate_method)\n            .expect(\"pythonize_checks\");\n\n        // Get the type of the original value\n        let value_type = py_value_without_constraints.bind(py).get_type();\n\n        // Collect check names as &str and turn them into a Python tuple\n        let check_names: Vec<&str> = checks.iter().map(|check| check.name.as_str()).collect();\n        let literal_args = PyTuple::new(py, check_names)?;\n\n        // Call Literal[...] dynamically\n        let literal_check_names = literal.get_item(literal_args).expect(\"get_item\");\n\n        let class_checked_type_constructor =\n            cls_module.getattr(\"Checked\").expect(\"getattr(Checked)\");\n\n        // Prepare type parameters for Checked[...]\n        let type_parameters_tuple =\n            PyTuple::new(py, [value_type.as_ref(), &literal_check_names]).expect(\"PyTuple::new\");\n\n        // Create the Checked type using __class_getitem__\n        let class_checked_type: Bound<'_, PyAny> = class_checked_type_constructor\n            .call_method1(\"__class_getitem__\", (type_parameters_tuple,))\n            .expect(\"__class_getitem__\");\n\n        // Prepare the properties dictionary\n        let properties_dict = pyo3::types::PyDict::new(py);\n        properties_dict.set_item(\"value\", py_value_without_constraints)?;\n        if !checks.is_empty() {\n            properties_dict.set_item(\"checks\", python_checks)?;\n        }\n\n        // Validate the model with the constructed type","sourceCodeStart":308,"sourceCodeEnd":344,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_python/src/types/function_results.rs#L308-L344","documentation":"pythonize_strict looks up the Checked generic class on the response's class module with cls_module.getattr(\"Checked\") and unwraps with expect(\"getattr(Checked)\"). Panic means the generated BAML client module does not define Checked, so checked fields cannot be typed.","triggerScenarios":"Parsing a response with checks when the generated client module (cls_module) is stale — generated before checks/Checked were supported — or module wasn't imported correctly.","commonSituations":"Out-of-date generated baml_client after upgrading the engine; custom modules passed as the class module that lack Checked; partially generated client code.","solutions":["Regenerate baml_client (baml-cli generate) so the module exports Checked","Upgrade baml-py/engine to matching versions","Ensure the class module passed to parsing is the generated baml_client module, not an arbitrary one","Reinstall the baml package if Checked is missing from baml_py"],"exampleFix":"// before\n# stale generated client without Checked\nimport old_baml_client as cls_module\n// after\nbaml-cli generate\nfrom baml_client import baml_module as cls_module","handlingStrategy":"validation","validationCode":"import baml_client\nassert hasattr(baml_client, \"Checked\"), \"regenerate baml_client: baml-cli generate\"","typeGuard":"def client_has_checked(mod) -> bool:\n    return hasattr(mod, \"Checked\")","tryCatchPattern":null,"preventionTips":["Run baml-cli generate after every schema/engine change","Don't pass arbitrary modules as the class module","Keep generated code committed and up to date","Verify Checked exists in a smoke test at startup"],"tags":["rust","pyo3","panic","checked-class"],"backgroundTag":"missing-dependency","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}