biomejs/biome · error
Expected root for comments with data
Error message
Expected root for comments with data
What it means
Error "Expected root for comments with data" thrown in biomejs/biome.
Source
Thrown at crates/biome_formatter/src/comments.rs:1017
#[cfg(not(debug_assertions))]
pub(crate) fn assert_formatted_all_comments(&self) {}
#[cfg(debug_assertions)]
pub(crate) fn assert_formatted_all_comments(&self) {
let has_unformatted_comments = self
.data
.comments
.all_parts()
.any(|comment| !comment.formatted.get());
if has_unformatted_comments {
let mut unformatted_comments = Vec::new();
for node in self
.data
.root
.as_ref()
.expect("Expected root for comments with data")
.descendants()
{
unformatted_comments.extend(self.leading_comments(&node).iter().filter_map(
|comment| {
(!comment.formatted.get()).then_some(DebugComment::Leading {
node: node.clone(),
comment,
})
},
));
unformatted_comments.extend(self.dangling_comments(&node).iter().filter_map(
|comment| {
(!comment.formatted.get()).then_some(DebugComment::Dangling {
node: node.clone(),
comment,
})
},
));View on GitHub (pinned to 405dedb0ff)
Solutions
- This is an internal formatter invariant violation; report it as a Biome bug with the source file that triggered it.
- Ensure the comments iterator only runs on a fully parsed root node.
Example fix
// Report at https://github.com/biomejs/biome/issues with a minimal repro
When it happens
Trigger: Thrown at crates/biome_formatter/src/comments.rs:1017 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of biomejs/biome@405dedb0ff (2026-08-20).
Data as JSON: /api/errors/c3f7ae9c856baa9b.
Report an issue: GitHub.