{"record":{"id":"2283837ead950240","repo":"BoundaryML/baml","slug":"no-color-diagnostics-do-not-invoke-the-message-highlighter","errorCode":null,"errorMessage":"no-color diagnostics do not invoke the message highlighter","messagePattern":"no-color diagnostics do not invoke the message highlighter","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"info","filePath":"baml_language/crates/baml_compiler_diagnostics/src/render.rs","lineNumber":221,"sourceCode":"                    file_paths,\n                    &handler,\n                    config.color,\n                    config.show_error_codes,\n                    message_highlighter,\n                ) {\n                    Ok(output) => output,\n                    Err(DiagnosticMessageHighlightError) => {\n                        let handler = miette_handler(None, false, diagnostic.severity);\n                        render_miette_with_handler(\n                            diagnostic,\n                            sources,\n                            file_paths,\n                            &handler,\n                            false,\n                            config.show_error_codes,\n                            None,\n                        )\n                        .expect(\"no-color diagnostics do not invoke the message highlighter\")\n                    }\n                }\n            }\n            DiagnosticFormat::Agent => render_agent(\n                diagnostic,\n                sources,\n                file_paths,\n                &mut path_cache,\n                config.color,\n                config.show_error_codes,\n            ),\n            DiagnosticFormat::Concise => render_concise(diagnostic, sources, file_paths),\n        })\n        .collect::<Vec<_>>()\n        .join(\"\\n\")\n}\n\n#[derive(Debug)]","sourceCodeStart":203,"sourceCodeEnd":239,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_compiler_diagnostics/src/render.rs#L203-L239","documentation":"In render_diagnostics_with_highlighters, when the DiagnosticFormat is human but color is disabled, the code renders with None as the message highlighter. Because no-color output never applies semantic message highlighting, the call is asserted infallible with this expect. It is an internal invariant: supplying no highlighter to the no-color path cannot produce a highlighting error.","triggerScenarios":"Never from user code directly: it fires only if render with a None highlighter and color=false unexpectedly returns Err inside the human-format branch of render_diagnostics_with_highlighters.","commonSituations":"A developer would only see this while hacking on the renderer itself — e.g. changing miette handler configuration so the no-color path still attempts semantic highlighting and fails.","solutions":["No user action required; the assertion protects an internal invariant.","If it panics, you are running a modified build: revert renderer changes so the no-color branch passes None with syntax highlighting disabled.","Replace the expect with proper error propagation if you intentionally add highlighting to the no-color path."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"let out = std::panic::catch_unwind(|| render_diagnostics_with_highlighters(&diag, &sources, &cfg, highlighter));\nif out.is_err() { /* fall back to plain no-color rendering */ }","preventionTips":["Do not modify the no-color render branch to attach a message highlighter.","Keep syntax highlighting disabled whenever color=false.","If extending the renderer, propagate errors instead of expect()."],"tags":["rust","rendering","diagnostics","invariant"],"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-14T05:17:10.506Z"}