{"record":{"id":"cf718786ed221505","repo":"cloudflare/quiche","slug":"expected-stream-send-on-stream-to-write-byte","errorCode":null,"errorMessage":"Expected stream_send on stream {} to write {} bytes, got {}","messagePattern":"Expected stream_send on stream (.+?) to write (.+?) bytes, got (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"h3i/src/client/mod.rs","lineNumber":125,"sourceCode":"pub(crate) type StreamParserMap = HashMap<u64, FrameParser>;\n\nfn validate_stream_send_result(\n    result: quiche::Result<usize>, expected: &ExpectedStreamSendResult,\n    stream_id: u64,\n) {\n    match expected {\n        ExpectedStreamSendResult::Ok => {\n            result.unwrap_or_else(|err| {\n                panic!(\n                    \"Expected stream_send on stream {} to succeed, but got: {:?}\",\n                    stream_id, err\n                )\n            });\n        },\n        ExpectedStreamSendResult::OkExact(expected_bytes) => {\n            match result {\n                Ok(actual_bytes) if actual_bytes == *expected_bytes => {},\n                Ok(actual_bytes) => panic!(\n                    \"Expected stream_send on stream {} to write {} bytes, got {}\",\n                    stream_id, expected_bytes, actual_bytes\n                ),\n                Err(err) => panic!(\n                    \"Expected stream_send on stream {} to write {} bytes, got error: {:?}\",\n                    stream_id, expected_bytes, err\n                ),\n            }\n        },\n        ExpectedStreamSendResult::Error(expected_err) => {\n            match result {\n                Ok(written) => panic!(\n                    \"Expected stream_send on stream {} to fail with {:?}, but wrote {} bytes\",\n                    stream_id, expected_err, written\n                ),\n                Err(actual_err) if &actual_err == expected_err => {},\n                Err(actual_err) => panic!(\n                    \"Expected stream_send on stream {} to fail with {:?}, got {:?}\",","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/cloudflare/quiche/blob/9f96daa2c22a4468b0036fb0a0a3894eee6498b8/h3i/src/client/mod.rs#L107-L143","documentation":"This panic comes from h3i's action validation when a script asserts that quiche's stream_send wrote an exact number of bytes, but it wrote a different amount. h3i executes scripted H3 actions against a connection and verifies each ExpectedStreamSendResult; a byte-count mismatch means the connection or stream state differed from what the script assumed (e.g. stream already closed, flow control limited the write). It is a test-harness assertion failure, not a runtime error you can catch in the library.","triggerScenarios":"Executing an ExecuteAction with ExpectedStreamSendResult::OkExact(n) where quiche_conn_stream_send returns Ok(m) with m != n on the given stream_id.","commonSituations":"Scripts written against one server reused against another with different flow-control windows; sending on a stream that already had partial data buffered; stream capacity reduced by peer MAX_STREAM_DATA after the script was authored.","solutions":["Print the actual bytes written and compare with the expected count; adjust the script's expected value or the payload size.","Check the stream's available send capacity (flow control / stream state) before the action; add a wait or frame-action for the peer's MAX_STREAM_DATA/MAX_DATA update.","If exact length doesn't matter, relax the assertion to ExpectedStreamSendResult::OkAny or just assert no error."],"exampleFix":"// before\nExpectedStreamSendResult::OkExact(1200),\n// after\nExpectedStreamSendResult::OkExact(written) // align with actual flow-control-limited write, or use OkAny","handlingStrategy":"validation","validationCode":"// before executing the action\nassert!(expected_bytes <= conn.stream_capacity(stream_id).unwrap_or(0),\n        \"stream {} cannot accept {} bytes\", stream_id, expected_bytes);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check stream_capacity / stream_writable before asserting exact write sizes.","Prefer OkAny or error-tolerant expectations unless byte-exactness is the test's purpose."],"tags":["h3i","stream-send","assertion","http3"],"backgroundTag":"invalid-argument-value","analyzedSha":"9f96daa2c22a4468b0036fb0a0a3894eee6498b8","analyzedAt":"2026-09-08T11:27:09.536Z","contentChangedAt":"2026-09-08T11:27:09.536Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}