{"record":{"id":"6d6e89de4a38628e","repo":"biomejs/biome","slug":"found-a-token-with-no-parent-6d6e89","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/graphql.rs","lineNumber":540,"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: GraphqlSyntaxNode| 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: &GraphqlSyntaxNode| {\n            node.parent()\n                .is_some_and(|parent| parent.kind() == GraphqlSyntaxKind::GRAPHQL_ROOT)\n        })\n        .unwrap_or(root_node);\n\n    let printed = biome_graphql_formatter::format_range(","sourceCodeStart":522,"sourceCodeEnd":558,"githubUrl":"https://github.com/biomejs/biome/blob/405dedb0ff65dd29927faf587f6542e3c29db248/crates/biome_service/src/file_handlers/graphql.rs#L522-L558","documentation":"Panic in the GraphQL format-on-type handler (graphql.rs:540). After finding the token at the offset, the handler calls token.parent(); tokens returned by token_at_offset on a parsed rowan tree always have a parent node because the tree root is a node. This panic is a defensive assertion for a detached/token-rooted tree that the normal parse path cannot produce.","triggerScenarios":"Not reachable through normal editor traffic; would require a detached token or a token-rooted syntax tree, neither of which tree.token_at_offset produces.","commonSituations":"Practically never observed; only plausible with hand-built trees in tests or after parser internals changed.","solutions":["Update to the latest Biome release","File an issue with the exact document and keystroke if you can reproduce it (https://github.com/biomejs/biome/issues)","If embedding biome_service, wrap on-type format calls in catch_unwind and degrade to no formatting"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"// LSP client - ignore a failed on-type format request\ntry {\n  await client.sendRequest('textDocument/onTypeFormatted', params);\n} catch {\n  // no-op: keep typing responsive, do not surface the error\n}","preventionTips":["Never make editor input depend on the success of onTypeFormatted","Pin a stable Biome release for editor integrations","File a bug with the exact buffer if this defensive panic ever fires"],"tags":["graphql","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"}