{"record":{"id":"21a9ab7d745d8e1d","repo":"BoundaryML/baml","slug":"unhandled-rule","errorCode":null,"errorMessage":"Unhandled rule: {:?}","messagePattern":"Unhandled rule: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-lib/ast/src/formatter/mod.rs","lineNumber":404,"sourceCode":"                    docs.push(RcDoc::space());\n                    docs.push(RcDoc::text(\"|\"));\n                    docs.push(RcDoc::space());\n                }\n                Rule::base_type_with_attr | Rule::non_union => {\n                    docs.push(pair_to_doc_text(pair));\n                }\n                _ => {\n                    docs.push(self.unhandled_rule_to_doc(pair)?);\n                }\n            }\n        }\n\n        Ok(())\n    }\n\n    fn unhandled_rule_to_doc<'a>(&self, pair: Pair<'a, Rule>) -> Result<RcDoc<'a, ()>> {\n        if self.fail_on_unhandled_rule {\n            Err(anyhow!(\"Unhandled rule: {:?}\", pair.as_rule()))\n        } else {\n            // Don't trim the str repr of unhandled rules, so\n            // we can see the original source.\n            Ok(RcDoc::text(pair.as_str()))\n        }\n    }\n}\n\nfn pair_to_doc_text(pair: Pair<'_, Rule>) -> RcDoc<'_, ()> {\n    RcDoc::text(pair.as_str().trim())\n}\n","sourceCodeStart":386,"sourceCodeEnd":416,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-lib/ast/src/formatter/mod.rs#L386-L416","documentation":"unhandled_rule_to_doc is the formatter's fallback for pest Rules it has no rendering strategy for. When format option fail_on_unhandled_rule is true it errors 'Unhandled rule: {:?}'; otherwise it returns the raw source text unchanged. It is raised from schema_to_doc and the type/field-type doc walkers.","triggerScenarios":"Calling format_schema with fail_on_unhandled_rule: true on a schema containing any construct the formatter version doesn't explicitly handle (newer syntax like certain attributes, generators, or type expressions).","commonSituations":"Formatting .baml files written for a newer BAML language version with an older formatter, or enabling the strict flag while the file uses rarely-used rules.","solutions":["Set fail_on_unhandled_rule to false so unknown rules pass through verbatim.","Upgrade baml to a version whose formatter handles the rule named in the message.","Rewrite the offending syntax to a construct the current formatter supports."],"exampleFix":"// before\nlet options = FormatOptions { indent_width: 2, fail_on_unhandled_rule: true };\n// after\nlet options = FormatOptions { indent_width: 2, fail_on_unhandled_rule: false };","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"let options_strict = FormatOptions { indent_width: 2, fail_on_unhandled_rule: true };\nlet formatted = match format_schema(source, &options_strict) {\n    Ok(f) => f,\n    Err(_) => format_schema(source, &FormatOptions { indent_width: 2, fail_on_unhandled_rule: false })?,\n};","preventionTips":["Leave fail_on_unhandled_rule = false in production tooling.","Upgrade BAML before adopting newly introduced language syntax.","Read the rule name in the message and check it against your formatter version's changelog."],"tags":["rust","formatting","unsupported-syntax","strict-mode"],"backgroundTag":"unsupported-operation","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"}