BoundaryML/baml · info
rendering without a message highlighter cannot fail semantic
Error message
rendering without a message highlighter cannot fail semantic highlighting
What it means
render_miette always passes None as the message highlighter and asserts that the render call cannot fail semantic highlighting. Since no highlighter is supplied, the miette render of a diagnostic with highlights is expected to succeed; any Err trips this expect. It documents that the no-highlighter rendering path is infallible with respect to semantic highlighting.
Source
Thrown at baml_language/crates/baml_compiler_diagnostics/src/render.rs:307
diagnostic: &Diagnostic,
sources: &HashMap<FileId, String>,
file_paths: &HashMap<FileId, PathBuf>,
highlights: &SourceHighlights,
color: bool,
show_error_codes: bool,
) -> String {
let highlighter = color.then(|| DiagnosticHighlighter::new(highlights, file_paths));
let handler = miette_handler(highlighter, color, diagnostic.severity);
render_miette_with_handler(
diagnostic,
sources,
file_paths,
&handler,
color,
show_error_codes,
None,
)
.expect("rendering without a message highlighter cannot fail semantic highlighting")
}
fn miette_handler(
highlighter: Option<DiagnosticHighlighter>,
color: bool,
severity: Severity,
) -> GraphicalReportHandler {
let mut theme = if color {
GraphicalTheme::unicode()
} else {
GraphicalTheme::unicode_nocolor()
};
if color {
theme.styles.highlights = annotation_styles(severity);
}
let mut handler = GraphicalReportHandler::new_themed(theme)
.with_links(false)
.with_urls(false)View on GitHub (pinned to bd85ce9dee)
Solutions
- No action needed for library users.
- If encountered in a modified build, propagate the error (return Result) instead of expect, or restore the None-highlighter configuration.
- Verify the diagnostic's message highlights are valid byte ranges into the message text if you construct diagnostics manually.
Defensive patterns
Strategy: try-catch
Try / catch
let rendered = std::panic::catch_unwind(|| render_miette(&diag, &sources, &cfg));
if rendered.is_err() { /* fall back to agent-format rendering */ } Prevention
- Keep render_miette's highlighter argument as None as designed.
- Ensure diagnostics carry highlight ranges within the message text bounds.
- When changing the render pipeline, return Result instead of expect.
When it happens
Trigger: Calling render_miette (via render_diagnostic) only panics if the underlying miette render with highlighter=None returns Err — an unexpected internal condition, not a user input problem.
Common situations: Seen only when modifying the crate: e.g. wiring a highlighter into render_miette or changing miette's GraphicalReportHandler setup so highlighting can fail on normal diagnostics.
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
- no-color diagnostics do not invoke the message highlighter
- 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/50473323f086c5cc.
Report an issue: GitHub.