{"record":{"id":"9427dda07b3529fb","repo":"sinelaw/fresh","slug":"no-data-piped-to-stdin","errorCode":null,"errorMessage":"No data piped to stdin","messagePattern":"No data piped to stdin","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/fresh-editor/src/main.rs","lineNumber":1738,"sourceCode":"    let stdin_stream = if stdin_requested {\n        if stdin_has_data() {\n            tracing::info!(\"Starting background stdin streaming\");\n            match start_stdin_streaming() {\n                Ok(stream_state) => {\n                    tracing::info!(\n                        \"Stdin streaming started, spool: {:?}\",\n                        stream_state.spool.path()\n                    );\n                    Some(stream_state)\n                }\n                Err(e) => {\n                    eprintln!(\"Error: Failed to start stdin streaming: {}\", e);\n                    return Err(e);\n                }\n            }\n        } else {\n            eprintln!(\"Error: --stdin or \\\"-\\\" specified but stdin is a terminal (no piped data)\");\n            anyhow::bail!(io::Error::new(\n                io::ErrorKind::InvalidInput,\n                \"No data piped to stdin\",\n            ));\n        }\n    } else {\n        None\n    };\n\n    // Determine working directory early for config loading\n    // Filter out \"-\" from files list since it's handled via stdin_stream\n    // Parse locations which may be local or remote (user@host:path)\n    let parsed_locations: Vec<ParsedLocation> = args\n        .files\n        .iter()\n        .filter(|f| *f != \"-\")\n        .map(|f| parse_location(f))\n        .collect::<AnyhowResult<Vec<_>>>()?;\n","sourceCodeStart":1720,"sourceCodeEnd":1756,"githubUrl":"https://github.com/sinelaw/fresh/blob/67894ca5463dbd7a89bb31add4627c27d6b79d83/crates/fresh-editor/src/main.rs#L1720-L1756","documentation":"The editor was invoked with --stdin or a '-' file argument, expecting piped data on stdin, but stdin is a terminal (no piped input available). It reports the problem on stderr and bails with an InvalidInput io::Error. There is nothing to read, so the operation cannot proceed.","triggerScenarios":"Running `fresh --stdin` or `fresh -` directly in an interactive terminal without piping anything into it, e.g. `fresh -` instead of `cat file | fresh -`.","commonSituations":"Forgetting the pipe when testing stdin mode; running the command from an IDE run-config or cron where no pipe is attached; a script's upstream command produced no output yet stdin is still a TTY.","solutions":["Pipe data into the command: `cat file.txt | fresh -` or `command-that-outputs | fresh --stdin`","Remove --stdin/'-' if you intended to open a file normally","In scripts, verify the upstream producer emits data before invoking the editor","When interactive use is intended, open the file directly rather than via stdin mode"],"exampleFix":"// before\nfresh -\n// after\ncat file.txt | fresh -\n# or open the file directly:\nfresh file.txt","handlingStrategy":"validation","validationCode":"use std::io::IsTerminal;\nif std::io::stdin().is_terminal() {\n    eprintln!(\"--stdin requires piped input\");\n    std::process::exit(2);\n}","typeGuard":"fn stdin_is_piped() -> bool {\n    use std::io::IsTerminal;\n    !std::io::stdin().is_terminal()\n}","tryCatchPattern":"match editor::launch(args) {\n    Err(e) if e.kind() == std::io::ErrorKind::InvalidInput => eprintln!(\"pipe data in: cat file | fresh -\"),\n    Err(e) => eprintln!(\"{e}\"),\n    Ok(()) => {},\n}","preventionTips":["Check isatty(stdin) before passing --stdin or '-'","Always pipe a producer into stdin mode: `cmd | fresh -`","Remove --stdin from IDE/cron run configurations that lack pipes"],"tags":["cli","stdin","pipe"],"backgroundTag":"missing-required-argument","analyzedSha":"67894ca5463dbd7a89bb31add4627c27d6b79d83","analyzedAt":"2026-09-13T15:04:03.701Z","contentChangedAt":"2026-09-13T15:04:03.701Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}