{"record":{"id":"cdc546a4929b012c","repo":"BoundaryML/baml","slug":"0-lib","errorCode":null,"errorMessage":"{0}","messagePattern":"\\{0\\}","errorType":"exception","errorClass":"FormatterError","httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_fmt/src/lib.rs","lineNumber":134,"sourceCode":"    pub indent_width: usize,\n}\nimpl Default for FormatOptions {\n    fn default() -> Self {\n        Self {\n            line_width: 100,\n            indent_width: CANONICAL_INDENT_WIDTH,\n        }\n    }\n}\n\n/// Canonical indentation used by the CLI, LSP, and default library formatter.\npub const CANONICAL_INDENT_WIDTH: usize = 4;\n\n#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]\npub enum FormatterError {\n    #[error(\"{0:?}\")]\n    ParseErrors(Vec<ParseError>),\n    #[error(\"{0}\")]\n    StrongAstError(#[from] ast::StrongAstError),\n}\n\n#[cfg(test)]\nmod format_options_tests {\n    use super::*;\n\n    #[test]\n    fn default_options_use_the_canonical_four_space_indent() {\n        let options = FormatOptions::default();\n        assert_eq!(CANONICAL_INDENT_WIDTH, 4);\n        assert_eq!(options.indent_width, CANONICAL_INDENT_WIDTH);\n        let formatted = format(\"function value() -> int {\\n  result\\n}\\n\", &options)\n            .expect(\"default formatter options should format a function body\");\n        assert_eq!(formatted, \"function value() -> int {\\n    result\\n}\\n\");\n    }\n}\n","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_fmt/src/lib.rs#L116-L152","documentation":"FormatterError::ParseErrors is thrown by the baml_fmt formatter when the source text cannot be parsed before formatting. thiserror renders the variant with `{0:?}`, so the message is the Debug representation of the Vec<ParseError>. Formatting requires a valid AST, so all parse failures are surfaced through this variant.","triggerScenarios":"Calling the formatter (e.g. format entry points in baml_fmt) on BAML source containing syntax errors; the parser produces a Vec<ParseError> which is wrapped via this variant.","commonSituations":"Running baml fmt on a file mid-edit; saving an incomplete BAML file with a formatter-on-save hook; CI format checks on a branch with broken syntax; a typo such as a missing brace or invalid expression.","solutions":["Fix the underlying BAML syntax errors reported by the parse errors before formatting","Run the parser or LSP diagnostics first to see the precise error locations","Exclude unparseable/generated files from the formatter in CI"],"exampleFix":"// before (formatting broken source directly)\nlet formatted = baml_fmt::format(src)?;\n// after\nmatch parser::parse(src) {\n    Ok(_) => baml_fmt::format(src)?,\n    Err(errs) => eprintln!(\"fix syntax first: {errs:?}\"),\n}","handlingStrategy":"validation","validationCode":"let parse_result = parser::parse(src);\nif let Err(errs) = parse_result {\n    eprintln!(\"cannot format, syntax errors: {errs:?}\");\n    return;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run formatter-on-save only after syntax checks pass (LSP diagnostics clean)","Add a parse check to CI before running fmt --check","Use editor BAML syntax highlighting to catch syntax errors early"],"tags":["formatter","parse-error","rust","baml"],"backgroundTag":"schema-validation-failed","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}