{"record":{"id":"abc6151e6acf903c","repo":"astral-sh/ruff","slug":"internalerror-abc615","errorCode":"InternalError","errorMessage":"Text document URI does not point to a text document","messagePattern":"Text document URI does not point to a text document","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/ruff_server/src/session/index.rs","lineNumber":114,"sourceCode":"    }\n\n    pub(super) fn notebook_document_uris(&self) -> impl Iterator<Item = &Uri> + '_ {\n        self.documents\n            .iter()\n            .filter(|(_, doc)| doc.as_notebook().is_some())\n            .map(|(uri, _)| uri)\n    }\n\n    pub(super) fn update_text_document(\n        &mut self,\n        key: &DocumentKey,\n        content_changes: Vec<lsp_types::TextDocumentContentChangeEvent>,\n        new_version: DocumentVersion,\n        encoding: PositionEncoding,\n    ) -> crate::Result<()> {\n        let controller = self.document_controller_for_key(key)?;\n        let Some(document) = controller.as_text_mut() else {\n            anyhow::bail!(\"Text document URI does not point to a text document\");\n        };\n\n        if content_changes.is_empty() {\n            document.update_version(new_version);\n            return Ok(());\n        }\n\n        document.apply_changes(content_changes, new_version, encoding);\n\n        Ok(())\n    }\n\n    pub(super) fn key_from_uri(&self, uri: Uri) -> DocumentKey {\n        if self.notebook_cells.contains_key(&uri) {\n            DocumentKey::NotebookCell(uri)\n        } else if self\n            .documents\n            .get(&uri)","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/astral-sh/ruff/blob/d1087a4b9e03d253a88703f34e0869ee4b805456/crates/ruff_server/src/session/index.rs#L96-L132","documentation":"An InternalError from ruff-server's document index: update_text_document (textDocument/didChange) looked up the controller for the given DocumentKey, but the stored document is not a TextDocument (as_text_mut returned None — typically it is a notebook controller). The server's view of what the URI holds disagrees with what the editor's change event claims.","triggerScenarios":"A textDocument/didChange arriving for a URI the server has registered as a notebook document (or a notebook-cell routing bug); usually after notebook open/close churn desynchronizes the index.","commonSituations":"Editors that re-open a notebook's underlying URI as a plain text document; rapid notebook cell edits racing a server restart; stale document state after the server reinitializes mid-session.","solutions":["Reload the editor window (or restart the ruff server) so didOpen/didClose state is rebuilt","Update the ruff editor extension — document-kind routing bugs are fixed upstream","Reproduce and report with LSP logs if it persists on the latest version"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Reload the window after server restarts so didOpen state matches the editor","Do not edit the same .ipynb as raw text and as a notebook simultaneously","Report persistent kind-mismatch errors with an LSP trace"],"tags":["lsp","ruff-server","document-sync","internal-error","state-desync"],"backgroundTag":"lsp-state-desync","analyzedSha":"d1087a4b9e03d253a88703f34e0869ee4b805456","analyzedAt":"2026-08-20T16:33:49.445Z","contentChangedAt":"2026-08-20T16:33:49.445Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}