{"record":{"id":"e23b65654bd7b021","repo":"Hmbown/CodeWhale","slug":"write-incomplete-reply","errorCode":null,"errorMessage":"write incomplete reply","messagePattern":"write incomplete reply","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/palette/src/osc11_tests.rs","lineNumber":90,"sourceCode":"        assert_eq!(\n            carried, prefix,\n            \"type-ahead before the reply must be replayable\"\n        );\n        assert_eq!(\n            remaining, suffix,\n            \"the input pump must still receive the exact suffix\"\n        );\n    }\n}\n\n#[test]\nfn terminal_reply_reader_retains_incomplete_control_reply_separately_from_typeahead() {\n    let (reader, mut writer) = std::io::pipe().expect(\"create isolated input pipe\");\n    let prefix = b\"/plu\";\n    let incomplete = b\"\\x1b]11;rgb:1e/1e\\r\\r\";\n    let burst = [prefix.as_slice(), incomplete.as_slice()].concat();\n    assert_eq!(\n        writer.write(&burst).expect(\"write incomplete reply\"),\n        burst.len()\n    );\n    drop(writer);\n\n    let (answered, reply, carried) = read_terminal_reply(\n        reader.as_raw_fd(),\n        b\"\\x1b]11;?\\x07\",\n        Duration::from_secs(1),\n        false,\n    );\n\n    assert!(\n        !answered,\n        \"an unterminated control reply is not a valid answer\"\n    );\n    assert_eq!(\n        reply, incomplete,\n        \"the caller must account for every unreplayable byte\"","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/crates/palette/src/osc11_tests.rs#L72-L108","documentation":"This is a `std::io::Write::write` Err surfaced through `expect('write incomplete reply')`, panicking the test. The library throws it when writing the synthesized terminal escape burst (`/plu` + a truncated OSC 11 reply) to the write end of the test pipe fails. Because the write end is a pipe, failure usually means the read end was already closed (EPIPE) or the descriptor is invalid — the fixture plumbing broke, not the code under test.","triggerScenarios":"`writer.write(&burst)` on a `std::io::pipe()` write half after the read half was dropped or closed; writing to an invalid raw fd; or a partial write loop aborted. Any Err from that call panics with this message.","commonSituations":"Refactoring the test so `drop(reader)` happens before the write; closing the read end in a helper; running under a sandbox where the pipe fd was closed by the environment.","solutions":["Ensure the pipe's read half stays alive until after all writes; only `drop(writer)` after writing (as this test does).","Inspect the io::Error kind: BrokenPipe means the reader side was closed first — fix the fixture ordering.","Handle short writes if swapping in a different writer: loop or use write_all so a partial write does not corrupt the burst."],"exampleFix":"// before\nwriter.write(&burst).expect(\"write incomplete reply\");\n// after\nwriter.write_all(&burst).expect(\"pipe write half closed before burst was written\");","handlingStrategy":"try-catch","validationCode":"// verify write half is still open before writing the burst\nassert!(matches!(writer.write(&[]), Ok(_)), \"pipe write end is closed (EPIPE) before writing burst\");","typeGuard":null,"tryCatchPattern":"match writer.write(&burst) {\n    Ok(n) if n == burst.len() => {},\n    Ok(n) => panic!(\"short write: {n}/{} bytes\", burst.len()),\n    Err(e) if e.kind() == std::io::ErrorKind::BrokenPipe =>\n        panic!(\"pipe reader was dropped before the burst was written: {e}\"),\n    Err(e) => panic!(\"write incomplete reply: {e}\"),\n}","preventionTips":["Use write_all instead of a single write to handle partial writes.","Keep the pipe's read half alive until all writes complete; drop the write half last.","On write failures, assert the exact byte count rather than trusting write's return value."],"tags":["rust","io","broken-pipe","test-harness"],"backgroundTag":"broken-pipe","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}