biomejs/biome · error
found a token with no parent
Error message
found a token with no parent
What it means
Panic in the JSON format-on-type handler (json.rs:612). After locating the token at the cursor, the handler calls token.parent(); tokens returned by token_at_offset on a parsed rowan tree always have a parent node since the root is a node. This is a defensive assertion for detached or token-rooted trees, which the normal parse path cannot produce.
Source
Thrown at crates/biome_service/src/file_handlers/json.rs:612
// File is empty, do nothing
TokenAtOffset::None => panic!("empty file"),
TokenAtOffset::Single(token) => token,
// The cursor should be right after the closing character that was just typed,
// select the previous token as the correct one
TokenAtOffset::Between(token, _) => token,
};
if token.text_trimmed_range().end() != offset {
return Ok(format_on_type_noop(offset));
}
if !matches_on_type_char(token.text_trimmed()) {
return Ok(format_on_type_noop(offset));
}
let root_node = match token.parent() {
Some(node) => node,
None => panic!("found a token with no parent"),
};
if root_node
.ancestors()
.any(|node: JsonSyntaxNode| node.kind().is_bogus())
{
return Ok(format_on_type_noop(offset));
}
let printed =
biome_json_formatter::format_range(options, &tree, root_node.text_trimmed_range())?;
Ok(printed)
}
fn lint(params: LintParams) -> LintResults {
let _ = debug_span!("Linting JSON file", path =? params.path, language =? params.language)
.entered();
let Some(file_source) = paramsView on GitHub (pinned to 405dedb0ff)
Solutions
- Update to the latest Biome release
- Report a reproducer to https://github.com/biomejs/biome/issues if you can trigger it
- Embedders: guard the call with catch_unwind and degrade to no formatting
Defensive patterns
Strategy: fallback
Try / catch
// LSP client - on-type formatting is best-effort
try {
const edits = await client.sendRequest('textDocument/onTypeFormatted', params);
} catch {
// ignore server-side failure; buffer stays as typed
} Prevention
- Never block user input on onTypeFormatted responses
- Pin a known-good Biome build in the editor integration
- Report reproductions; this defensive panic should not be reachable
When it happens
Trigger: Not reachable through normal LSP requests; only a detached token or a token as tree root would trigger it.
Common situations: Effectively theoretical; only plausible with hand-constructed syntax trees or internal API misuse.
Related errors
- found a token with no parent
- found a token with no parent
- found a token with no parent
- empty file
- found a token with no parent
AI-assisted analysis of biomejs/biome@405dedb0ff (2026-08-20).
Data as JSON: /api/errors/dcb1fc3e29e96ef5.
Report an issue: GitHub.