astral-sh/ruff · error · anyhow::Error

Text document URI does not point to a text document

Error message

Text document URI does not point to a text document

What it means

Error "Text document URI does not point to a text document" thrown in astral-sh/ruff.

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 672bb4edf0)

When it happens

Trigger: Thrown at crates/ruff_server/src/session/index.rs:114 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of astral-sh/ruff@672bb4edf0 (2026-08-16). Data as JSON: /api/errors/279ef325b36ced5d. Report an issue: GitHub.