{"record":{"id":"e175d80d29108244","repo":"biomejs/biome","slug":"found-a-token-with-no-parent-e175d8","errorCode":null,"errorMessage":"found a token with no parent","messagePattern":"found a token with no parent","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/biome_service/src/file_handlers/grit.rs","lineNumber":477,"sourceCode":"        // File is empty, do nothing\n        TokenAtOffset::None => panic!(\"empty file\"),\n        TokenAtOffset::Single(token) => token,\n        // The cursor should be right after the closing character that was just typed,\n        // select the previous token as the correct one\n        TokenAtOffset::Between(token, _) => token,\n    };\n\n    if token.text_trimmed_range().end() != offset {\n        return Ok(format_on_type_noop(offset));\n    }\n\n    if !matches_on_type_char(token.text_trimmed()) {\n        return Ok(format_on_type_noop(offset));\n    }\n\n    let root_node = match token.parent() {\n        Some(node) => node,\n        None => panic!(\"found a token with no parent\"),\n    };\n\n    if root_node\n        .ancestors()\n        .any(|node: GritSyntaxNode| node.kind().is_bogus())\n    {\n        return Ok(format_on_type_noop(offset));\n    }\n\n    let formatting_root = root_node\n        .ancestors()\n        .find(|node: &GritSyntaxNode| {\n            node.parent()\n                .is_some_and(|parent| parent.kind() == GritSyntaxKind::GRIT_ROOT)\n        })\n        .unwrap_or(root_node);\n\n    let printed =","sourceCodeStart":459,"sourceCodeEnd":495,"githubUrl":"https://github.com/biomejs/biome/blob/405dedb0ff65dd29927faf587f6542e3c29db248/crates/biome_service/src/file_handlers/grit.rs#L459-L495","documentation":"Panic in the Grit format-on-type handler (grit.rs:477). The handler calls token.parent() on the token found at the cursor; in rowan trees the root is a node, so tokens from token_at_offset always have a parent. This is a defensive assertion for a state (detached or token-rooted tree) the parser cannot produce.","triggerScenarios":"Not reachable via normal LSP requests; only a detached token or token-rooted tree would trigger it.","commonSituations":"Essentially theoretical; surfacing only with hand-constructed trees or internal API misuse.","solutions":["Update to the latest Biome release","Report a reproducer (document + keystroke) to https://github.com/biomejs/biome/issues if found","Embedders: guard on-type formatting with catch_unwind and treat failure as no-op"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"// LSP client - best-effort on-type formatting\ntry {\n  const edits = await client.sendRequest('textDocument/onTypeFormatted', params);\n} catch {\n  // ignore: formatting is optional, typing must never block\n}","preventionTips":["Wrap all optional formatting requests in best-effort error handling","Pin a known-good Biome version","Report reproductions upstream; this arm should be unreachable in practice"],"tags":["grit","lsp","format-on-type","panic","defensive-check"],"backgroundTag":"syntax-token-no-parent","analyzedSha":"405dedb0ff65dd29927faf587f6542e3c29db248","analyzedAt":"2026-08-20T00:25:09.682Z","contentChangedAt":"2026-08-20T00:25:09.682Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}