facebook/flow · error

check-contents input should be readable

Error message

check-contents input should be readable

What it means

The check-contents command handler converts the wire FileInput to a server file input and calls content_of_file_input() — the Result-returning read — but immediately expects Ok with 'check-contents input should be readable' (rust_port/crates/flow_server/src/standalone.rs:1547-1549). The Err case comes from std::fs::read_to_string on the FileInput::FileName variant: missing file, permission denied, or non-UTF-8 bytes. A recoverable I/O problem therefore crashes the server with a panic instead of returning an error response.

Source

Thrown at rust_port/crates/flow_server/src/standalone.rs:1548

    options: &Options,
    input: server_socket_rpc::FileInput,
    verbose: Option<flow_common::verbose::Verbose>,
    force: bool,
    error_flags: cli_output::ErrorFlags,
    strip_root: bool,
    json: bool,
    pretty: bool,
    json_version: Option<flow_common_errors::error_utils::json_output::JsonVersion>,
    offset_kind: flow_parser::offset_utils::OffsetKind,
) -> Result<ServerResponse, CheckedDependenciesCanceled> {
    let mut options = options.clone();
    options.all = options.all || force;
    options.verbose = verbose.map(Arc::new);
    let wire_input = input.clone();
    let input = input.into_server_file_input();
    let content = input
        .content_of_file_input()
        .expect("check-contents input should be readable");
    let file_key = match &wire_input {
        server_socket_rpc::FileInput::FileName(path)
        | server_socket_rpc::FileInput::FileContent(Some(path), _) => {
            FileKey::source_file_of_absolute(path)
        }
        server_socket_rpc::FileInput::FileContent(None, _) => FileKey::source_file_of_absolute("-"),
    };
    let intermediate_result = flow_services_inference::type_contents::parse_contents(
        &options,
        env.all_unordered_libs.dupe(),
        &content,
        &file_key,
    );
    if intermediate_result.0.is_none() && intermediate_result.1.is_empty() {
        let error_output = if json {
            let mut buf = Vec::new();
            flow_common_errors::error_utils::json_output::print_errors_with_offset_kind(
                &mut buf,

View on GitHub (pinned to f88ac94bcf)

Solutions

  1. Send FileInput::FileContent(Some(name), Some(contents)) to inline the text and skip the server-side read
  2. Pre-check on the client that the file exists and is readable before sending a FileName-based request
  3. Use absolute paths the server process can resolve
  4. Upstream: replace the expect with a ServerResponse error built from the Err(String) value

Example fix

// before
let content = input
    .content_of_file_input()
    .expect("check-contents input should be readable");

// after
let content = input
    .content_of_file_input()
    .map_err(|e| ServerResponse::error(format!("check-contents: cannot read input: {e}")))?;
Defensive patterns

Strategy: validation

Validate before calling

// Client-side pre-check before sending a FileName-based check-contents request
match std::fs::read(&path) {
    Ok(bytes) => send(FileContent(Some(path), Some(String::from_utf8_lossy(&bytes).into_owned()))),
    Err(e) => return Err(format!("cannot read {path}: {e}")),
}

Type guard

fn readable_utf8(path: &str) -> bool {
    std::fs::read(path).map(|b| std::str::from_utf8(&b).is_ok()).unwrap_or(false)
}

Prevention

When it happens

Trigger: Sending a check-contents request whose FileInput::FileName names a file deleted between request construction and handling, unreadable due to permissions, or containing invalid UTF-8. FileContent-based requests inline the text and never hit this path.

Common situations: Editor flows racing file deletion or rename; containers where the path is bind-mounted differently than the client expects; clients passing relative paths that resolve against a different server working directory.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


AI-assisted analysis of facebook/flow@f88ac94bcf (2026-08-20). Data as JSON: /api/errors/8fe907d137f037c2. Report an issue: GitHub.