tinyhumansai/openhuman · error

failed to read stdin: {e}

Error message

failed to read stdin: {e}

What it means

Reading raw text from stdin (invoked by passing `--file -` to the tree-summarizer ingest subcommand) hit an I/O error. Stdin is consumed with `read_to_string`, so this fires when the pipe is broken (e.g. `echo foo | head -c 0` closing early), stdin is a terminal with no input redirected, or the input stream contains invalid UTF-8 — the byte-level failure is chained in the message.

Source

Thrown at src/openhuman/memory/tree/tree_runtime/cli.rs:134

        println!();
        println!("  <namespace>          Target namespace for the summary tree");
        println!("  --content, -c <text> Raw text content to ingest");
        println!("  --file, -f <path>    Read content from a file (use - for stdin)");
        println!("  -v, --verbose        Enable debug logging");
        println!();
        println!("Either --content or --file is required. If both are given, --file wins.");
        return Ok(());
    }

    let namespace = &rest[0];

    let content = if let Some(ref path) = opts.file {
        if path == "-" {
            use std::io::Read;
            let mut buf = String::new();
            std::io::stdin()
                .read_to_string(&mut buf)
                .map_err(|e| anyhow::anyhow!("failed to read stdin: {e}"))?;
            buf
        } else {
            std::fs::read_to_string(path)
                .map_err(|e| anyhow::anyhow!("failed to read '{}': {e}", path))?
        }
    } else if let Some(ref text) = opts.content {
        text.clone()
    } else {
        return Err(anyhow::anyhow!(
            "either --content or --file is required. Run `openhuman tree-summarizer ingest --help`."
        ));
    };

    if content.trim().is_empty() {
        return Err(anyhow::anyhow!("content is empty"));
    }

    init_logging(opts.verbose);

View on GitHub (pinned to 7491200858)

Solutions

  1. Check that stdin is actually piped or redirected: `cat file.txt | openhuman tree-summarizer ingest ns --file -`
  2. If feeding from another command, make sure that command exits successfully and writes valid UTF-8
  3. For a regular file, pass `--file <path>` instead of routing it through stdin
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at src/openhuman/memory/tree/tree_runtime/cli.rs:134 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of tinyhumansai/openhuman@7491200858 (2026-08-17). Data as JSON: /api/errors/1826c50f038722d8. Report an issue: GitHub.