{"record":{"id":"b510dfcbb9cb0f05","repo":"facebook/flow","slug":"failed-to-write-not-covered-output","errorCode":null,"errorMessage":"failed to write not-covered output","messagePattern":"failed to write not-covered output","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"rust_port/crates/flow_cli/src/check_contents_command.rs","lineNumber":208,"sourceCode":"            } else {\n                let stdout = std::io::stdout();\n                let mut out = stdout.lock();\n                writeln!(out, \"No errors!\").expect(\"failed to write success output\");\n                out.flush().expect(\"failed to flush success output\");\n            }\n            flow_common_exit_status::exit(flow_common_exit_status::FlowExitStatus::NoError)\n        }\n        server_prot::response::StatusResponse::NOT_COVERED => {\n            if json {\n                print_json(\n                    &ConcreteLocPrintableErrorSet::empty(),\n                    &ConcreteLocPrintableErrorSet::empty(),\n                    &[],\n                )\n            } else {\n                let stdout = std::io::stdout();\n                let mut out = stdout.lock();\n                writeln!(out, \"File is not @flow!\").expect(\"failed to write not-covered output\");\n                out.flush().expect(\"failed to flush not-covered output\");\n            }\n            flow_common_exit_status::exit(flow_common_exit_status::FlowExitStatus::NoError)\n        }\n    }\n}\n\npub(crate) fn command() -> flow_command_spec::Command {\n    flow_command_spec::command(spec(), main)\n}\n","sourceCodeStart":190,"sourceCodeEnd":219,"githubUrl":"https://github.com/facebook/flow/blob/5c865861998a8ccb7dbc82b0c1f511e9ef60c3d9/rust_port/crates/flow_cli/src/check_contents_command.rs#L190-L219","documentation":"NOT_COVERED branch of check-contents: the checked file lacks the `@flow` pragma (and --all was not passed), so the server reports not covered and the CLI writes the single line 'File is not @flow!' to stdout. The .expect() panics when that write fails — in practice when the pipe reader already exited (EPIPE) or stdout points to a full/closed target.","triggerScenarios":"`flow check-contents module.js | true` where module.js has no `@flow` comment and the consumer exits without reading; piping the result into a probe that exits on unrelated input; stdout closed or /dev/full.","commonSituations":"Batch scripts checking many files where some lack the pragma, piped into early-exiting filters; wrappers that close stdout early on their own error paths.","solutions":["Capture to a file: `flow check-contents module.js > out.txt` and inspect it afterwards","Keep the downstream consumer alive until EOF, or add `| cat` as a buffer","Pass --all if you intend to check files without the @flow pragma, avoiding surprise output shape","Maintainer: match the writeln result and exit(141) on BrokenPipe instead of expect"],"exampleFix":"// before\nwriteln!(out, \"File is not @flow!\").expect(\"failed to write not-covered output\");\n\n// after\nif let Err(e) = writeln!(out, \"File is not @flow!\") {\n    if e.kind() == std::io::ErrorKind::BrokenPipe {\n        std::process::exit(141);\n    }\n    panic!(\"failed to write not-covered output: {e}\");\n}","handlingStrategy":"try-catch","validationCode":"// Know the output shape up front: files without the @flow pragma\n// (and no --all) produce 'File is not @flow!' — probe that on a saved file:\n// flow check-contents module.js > out.txt; grep -F 'not @flow' out.txt","typeGuard":null,"tryCatchPattern":"if let Err(e) = writeln!(out, \"File is not @flow!\") {\n    if e.kind() == std::io::ErrorKind::BrokenPipe {\n        std::process::exit(141);\n    }\n    panic!(\"failed to write not-covered output: {e}\");\n}","preventionTips":["Use --all when checking files that may lack the @flow pragma","Use --json to get structured status instead of parsing prose lines","Never pipe short-status output into early-exiting probes"],"tags":["rust","flow-cli","stdout","broken-pipe","flow-pragma","panic"],"backgroundTag":"broken-pipe","analyzedSha":"5c865861998a8ccb7dbc82b0c1f511e9ef60c3d9","analyzedAt":"2026-08-20T10:41:37.992Z","contentChangedAt":"2026-08-20T10:41:37.992Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}