{"record":{"id":"5fc9dc75cbeb19f6","repo":"denoland/deno","slug":"failed-to-read-from-stdin-5fc9dc","errorCode":null,"errorMessage":"Failed to read from stdin","messagePattern":"Failed to read from stdin","errorType":"exception","errorClass":"AnyError","httpStatus":null,"severity":"error","filePath":"cli/tools/lint/mod.rs","lineNumber":613,"sourceCode":") -> Result<bool, AnyError> {\n  let start_dir = &cli_options.start_dir;\n  let reporter_lock = Arc::new(Mutex::new(create_reporter(\n    workspace_lint_options.reporter_kind,\n  )));\n  let lint_config = start_dir\n    .to_lint_config(FilePatterns::new_with_base(start_dir.dir_path()))?;\n  let deno_lint_config =\n    resolve_lint_config(compiler_options_resolver, start_dir.dir_url())?;\n  let lint_options = LintOptions::resolve(lint_config, &lint_flags)?;\n  let configured_rules = lint_rule_provider\n    .resolve_lint_rules_err_empty(lint_options.rules, Some(start_dir))?;\n  let mut file_path = cli_options.initial_cwd().join(STDIN_FILE_NAME);\n  if let Some(ext) = cli_options.ext_flag() {\n    file_path.set_extension(ext);\n  }\n  let mut source_code = String::new();\n  if stdin().read_to_string(&mut source_code).is_err() {\n    return Err(anyhow!(\"Failed to read from stdin\"));\n  }\n\n  let linter = CliLinter::new(CliLinterOptions {\n    fix: false,\n    configured_rules,\n    deno_lint_config,\n    maybe_plugin_runner: None,\n  });\n\n  let r = linter.lint_file(&file_path, deno_ast::strip_bom(source_code), None);\n\n  let success =\n    handle_lint_result(&file_path.to_string_lossy(), r, reporter_lock.clone());\n  reporter_lock.lock().close(1);\n  Ok(success)\n}\n\nfn handle_lint_result(","sourceCodeStart":595,"sourceCodeEnd":631,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/tools/lint/mod.rs#L595-L631","documentation":"When linting standard input (`deno lint -`), Deno reads all of stdin into a string before linting; if read_to_string fails — stdin closed or unreadable, an OS-level read error, or non-UTF-8 bytes — it aborts with this message. The underlying io::Error is swallowed, so the wording stays generic.","triggerScenarios":"`deno lint -` where stdin is not a readable pipe (no input attached in CI or service contexts), the upstream writer fails mid-stream (broken pipe), or the piped bytes are not valid UTF-8 (binary data, still-compressed output).","commonSituations":"CI jobs invoking `deno lint -` unconditionally with stdin closed; piping compressed or binary content by mistake (a forgotten gunzip); producers that exit before writing anything; terminal-less service environments.","solutions":["Make sure input is actually piped: `deno lint - < src/mod.ts` or `echo 'const x = 1;' | deno lint -`","Ensure the stream is UTF-8 text — decompress and strip binaries before piping","In scripts, only use `-` when input is guaranteed (test that stdin is a pipe first)"],"exampleFix":"# before (CI, stdin never attached)\ndeno lint -\n\n# after\ndeno lint - < src/mod.ts","handlingStrategy":"validation","validationCode":"// only pass '-' when stdin is a pipe with data available\nconst st = await Deno.stat('/dev/stdin').catch(() => null);\nconst isPipe = st !== null && !st.isTerminal;\nif (!isPipe) {\n  console.error('nothing piped into deno lint -');\n  Deno.exit(1);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always redirect stdin from a file or producer in scripts","Decode and validate UTF-8 before piping into lint","Prefer linting files directly when stdin availability is uncertain"],"tags":["lint","stdin","io","utf-8"],"backgroundTag":"stdin-read-failed","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}