BoundaryML/baml · info
no-color diagnostics do not invoke the message highlighter
Error message
no-color diagnostics do not invoke the message highlighter
What it means
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.
Source
Thrown at baml_language/crates/baml_compiler_diagnostics/src/render.rs:221
file_paths,
&handler,
config.color,
config.show_error_codes,
message_highlighter,
) {
Ok(output) => output,
Err(DiagnosticMessageHighlightError) => {
let handler = miette_handler(None, false, diagnostic.severity);
render_miette_with_handler(
diagnostic,
sources,
file_paths,
&handler,
false,
config.show_error_codes,
None,
)
.expect("no-color diagnostics do not invoke the message highlighter")
}
}
}
DiagnosticFormat::Agent => render_agent(
diagnostic,
sources,
file_paths,
&mut path_cache,
config.color,
config.show_error_codes,
),
DiagnosticFormat::Concise => render_concise(diagnostic, sources, file_paths),
})
.collect::<Vec<_>>()
.join("\n")
}
#[derive(Debug)]View on GitHub (pinned to bd85ce9dee)
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.
Defensive patterns
Strategy: try-catch
Try / catch
let out = std::panic::catch_unwind(|| render_diagnostics_with_highlighters(&diag, &sources, &cfg, highlighter));
if out.is_err() { /* fall back to plain no-color rendering */ } Prevention
- 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().
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- rendering without a message highlighter cannot fail semantic
- writing to a String cannot fail
- colored diagnostics have a source highlighter
- diagnostic message style code is a valid Unicode variation s
- Package.current call site names a loaded package
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/2283837ead950240.
Report an issue: GitHub.