{"record":{"id":"6cf5d97b0d70aca6","repo":"dbt-labs/dbt-core","slug":"failed-to-write-show-data-to-stdout","errorCode":null,"errorMessage":"failed to write show data to stdout","messagePattern":"failed to write show data to stdout","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/dbt-common/src/tracing/layers/tui_layer.rs","lineNumber":1428,"sourceCode":"                        .write_all(format!(\"{}\\n\", header).as_bytes())\n                        .expect(\"failed to write header to stdout\");\n                }\n\n                // Print list item content (always — result payload survives quiet)\n                stdout\n                    .write_all(format!(\"{}\\n\", list_item.content).as_bytes())\n                    .expect(\"failed to write to stdout\");\n            });\n        }\n    }\n\n    fn handle_show_data_output(&self, show_data: &ShowDataOutput) {\n        self.write_suspended(|| {\n            let mut stdout = io::stdout().lock();\n\n            stdout\n                .write_all(format!(\"{}\\n\", show_data.content).as_bytes())\n                .expect(\"failed to write show data to stdout\");\n        });\n    }\n\n    fn handle_show_result(&self, show_result: &ShowResult) {\n        self.write_suspended(|| {\n            let mut stdout = io::stdout().lock();\n\n            if self.show_options.is_empty() {\n                // Quiet mode: suppress decorative title, emit raw content only.\n                // Mirrors dbt-core's ShowNode quiet=True behaviour where the\n                // \"Previewing node 'X':\" header is dropped but the data is kept.\n                stdout\n                    .write_all(format!(\"{}\\n\", show_result.content).as_bytes())\n                    .expect(\"failed to write show result to stdout\");\n            } else {\n                let colored_title = BLUE.apply_to(&show_result.title);\n                stdout\n                    .write_all(format!(\"\\n{}\\n{}\\n\", colored_title, show_result.content).as_bytes())","sourceCodeStart":1410,"sourceCodeEnd":1446,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-common/src/tracing/layers/tui_layer.rs#L1410-L1446","documentation":"handle_show_data_output writes show-query content to a locked stdout with .expect('failed to write show data to stdout'), panicking on write failure. The `dbt show` results must reach the terminal, so the layer treats write failure as fatal. The write fails when stdout's consumer has vanished or the target is unwritable.","triggerScenarios":"A ShowDataOutput record arrives via on_log_record and write_all fails: pipe reader exited, pty closed, or redirected file cannot accept data (ENOSPC).","commonSituations":"`dbt show ... | head` truncating consumers; running under a wrapper that closed stdout; disk-quota errors when redirecting show output.","solutions":["Pipe into tee to a file rather than commands that exit early","Check disk space/quota on the redirect target","Keep the capturing harness alive until dbt exits","Make the write non-fatal (warn and continue) instead of .expect"],"exampleFix":"// before\n.expect(\"failed to write show data to stdout\");\n// after\nif let Err(e) = stdout.write_all(format!(\"{}\\n\", show_data.content).as_bytes()) {\n    eprintln!(\"warning: could not write show data: {e}\");\n}","handlingStrategy":"try-catch","validationCode":"# preflight disk space and descriptor before show\ndf -h . && dbt show --inline 'select 1' > show_out.txt 2>&1","typeGuard":"fn stdout_writable() -> bool {\n    use std::io::Write;\n    io::stdout().flush().is_ok()\n}","tryCatchPattern":"// detect failure and fall back to file output\ndbt show --inline 'select 1' 2>err.log || { grep -q 'failed to write show data to stdout' err.log && dbt show --inline 'select 1' > out.txt; }","preventionTips":["Redirect show results to files when piping into truncating tools","Verify free space/quota for redirect targets","Do not close the terminal or consumer mid-show","Use tee for live viewing plus durable capture"],"tags":["stdout","io","broken-pipe","dbt-show"],"backgroundTag":"broken-pipe","analyzedSha":"0267ce9170576975b76b64ce856b2e5848e96617","analyzedAt":"2026-09-07T21:53:39.732Z","contentChangedAt":"2026-09-07T21:53:39.732Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}