astral-sh/ruff · error
InternalError
InternalError
Error message
Text document URI does not point to a text document
What it means
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.
Source
Thrown at crates/ruff_server/src/session/index.rs:114
}
pub(super) fn notebook_document_uris(&self) -> impl Iterator<Item = &Uri> + '_ {
self.documents
.iter()
.filter(|(_, doc)| doc.as_notebook().is_some())
.map(|(uri, _)| uri)
}
pub(super) fn update_text_document(
&mut self,
key: &DocumentKey,
content_changes: Vec<lsp_types::TextDocumentContentChangeEvent>,
new_version: DocumentVersion,
encoding: PositionEncoding,
) -> crate::Result<()> {
let controller = self.document_controller_for_key(key)?;
let Some(document) = controller.as_text_mut() else {
anyhow::bail!("Text document URI does not point to a text document");
};
if content_changes.is_empty() {
document.update_version(new_version);
return Ok(());
}
document.apply_changes(content_changes, new_version, encoding);
Ok(())
}
pub(super) fn key_from_uri(&self, uri: Uri) -> DocumentKey {
if self.notebook_cells.contains_key(&uri) {
DocumentKey::NotebookCell(uri)
} else if self
.documents
.get(&uri)View on GitHub (pinned to d1087a4b9e)
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
Defensive patterns
Strategy: fallback
Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of astral-sh/ruff@d1087a4b9e (2026-08-20).
Data as JSON: /api/errors/abc6151e6acf903c.
Report an issue: GitHub.