{"record":{"id":"36bf93f8801bc87a","repo":"BoundaryML/baml","slug":"pythonize-checks","errorCode":null,"errorMessage":"pythonize_checks","messagePattern":"pythonize_checks","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"engine/language_client_python/src/types/function_results.rs","lineNumber":313,"sourceCode":"\n            Ok(instance.into())\n        }\n        BamlValueWithMeta::Null(_) => Ok(py.None()),\n    }?;\n\n    let ResponseValueMeta(_, checks, completion_state, _) = meta;\n    if checks.is_empty() && !completion_state.display {\n        return Ok(py_value_without_constraints);\n    }\n\n    // Import the necessary modules and objects\n    let typing = py.import(\"typing\").expect(\"typing\");\n    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","sourceCodeStart":295,"sourceCodeEnd":331,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_python/src/types/function_results.rs#L295-L331","documentation":"In pythonize_strict (Rust/PyO3), when an LLM response value has checks, the code calls pythonize_checks to build Python validation expressions and unwraps with expect(\"pythonize_checks\"). A panic here means check generation failed — typically the Checked class or model_validate target is missing/misconfigured in the BAML Python runtime.","triggerScenarios":"Parsing an LLM response that includes checks when the corresponding Python module lacks the expected Checked infrastructure, or cls_module/model_validate_method is invalid.","commonSituations":"Mismatched baml-py runtime and Rust client versions; custom class modules that don't provide Checked; corrupted or partial installation of the baml package.","solutions":["Reinstall/upgrade the baml Python package so baml_py.Checked exists","Align BAML client codegen version with the engine version","Remove or fix custom checks in the BAML schema causing generation failure","File a bug with the schema if pythonize_checks panics on valid input"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"import baml_py\nassert hasattr(baml_py, \"Checked\"), \"baml runtime missing Checked support\"","typeGuard":"def runtime_supports_checks() -> bool:\n    import baml_py\n    return hasattr(baml_py, \"Checked\")","tryCatchPattern":null,"preventionTips":["Keep engine and baml-py versions in lockstep","Regenerate clients after upgrades","Test check-bearing schemas in CI","Avoid hand-editing generated client modules"],"tags":["rust","pyo3","panic","checks"],"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-23T08:17:48.524Z"}