astral-sh/ruff · error

Input is not a text document

Error message

Input is not a text document: {path}

What it means

A std::io::Error (InvalidInput) built by not_a_text_document in the ty server's virtual file system: a read targeted a virtual path that is not one of the open LSP text documents. The server only serves file contents for documents it holds in memory.

Solutions

  1. Open the file in the editor so it becomes a known text document
  2. Read from the real filesystem path instead of the virtual document path
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at crates/ty_server/src/system.rs:338 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of astral-sh/ruff@26f38c119c (2026-09-05). Data as JSON: /api/errors/2e0ea8458375a782. Report an issue: GitHub.

Appendix: source

Thrown at crates/ty_server/src/system.rs:338

/// Rejects commands without retaining the LSP document index.
struct UntrustedWorkspaceExecutor;

impl CommandExecutor for UntrustedWorkspaceExecutor {
    fn execute(&self, _command: Command) -> Result<Output> {
        Err(std::io::Error::new(
            std::io::ErrorKind::PermissionDenied,
            "external commands are disabled in an untrusted workspace",
        ))
    }

    fn dyn_clone(&self) -> Box<dyn CommandExecutor> {
        Box::new(Self)
    }
}

fn not_a_text_document(path: impl Display) -> std::io::Error {
    std::io::Error::new(
        std::io::ErrorKind::InvalidInput,
        format!("Input is not a text document: {path}"),
    )
}

fn virtual_path_not_found(path: impl Display) -> std::io::Error {
    std::io::Error::new(
        std::io::ErrorKind::NotFound,
        format!("Virtual path does not exist: {path}"),
    )
}

/// Helper function to get the [`FileRevision`] of the given document.
fn document_revision(document: &Document, index: &Index) -> FileRevision {
    // The file revision is just an opaque number which doesn't have any significant meaning other
    // than that the file has changed if the revisions are different.
    #[expect(clippy::cast_sign_loss)]
    match document {

View on GitHub (pinned to 26f38c119c)