Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,15 @@ increment the patch version.

### Fixed

- **Malformed Connect END_STREAM JSON now returns `internal`** ([#192]).
A streaming Connect response whose END_STREAM envelope body was not valid
JSON was silently treated as a clean `Ok(None)` close (the parse error fell
through `unwrap_or_default()`). It now returns `Err(internal)` with the
- **Malformed Connect END_STREAM JSON now returns `internal`** ([#192],
[#201]). A streaming Connect response whose END_STREAM envelope body was not
valid JSON was silently treated as a clean `Ok(None)` close (the parse error
fell through `unwrap_or_default()`). It now returns `Err(internal)` with the
serde error in the message, matching connect-go's behaviour for the same
case. Well-formed END_STREAM payloads (including the `null-error`,
`missing-code`, and unknown-field conformance shapes) are unchanged.
case, and the error carries the response headers on both the
server-streaming and client-streaming paths. Well-formed END_STREAM payloads
(including the `null-error`, `missing-code`, and unknown-field conformance
shapes) are unchanged.
- **Connect client-streaming responses require the END_STREAM envelope**
([#163]). A response that ended after its single data message but before
the END_STREAM envelope was accepted as a success with empty trailers, so
Expand All @@ -191,6 +193,7 @@ increment the patch version.
[#194]: https://github.com/anthropics/connect-rust/pull/194
[#197]: https://github.com/anthropics/connect-rust/pull/197
[#199]: https://github.com/anthropics/connect-rust/pull/199
[#201]: https://github.com/anthropics/connect-rust/pull/201
[connectrpc/conformance#1104]: https://github.com/connectrpc/conformance/pull/1104

## [0.7.0] - 2026-06-10
Expand Down
15 changes: 13 additions & 2 deletions connectrpc/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2639,7 +2639,10 @@ where

let end_stream = match parse_connect_end_stream(&end_stream_data) {
Ok(end_stream) => end_stream,
Err(e) => return e.into(),
Err(mut e) => {
e.set_response_headers(self.headers.clone());
return e.into();
}
};

let trailers = end_stream.metadata.map(|metadata| {
Expand Down Expand Up @@ -4427,8 +4430,11 @@ mod tests {
);
body.extend_from_slice(&Envelope::end_stream(Bytes::from_static(b"not json")).encode());

let mut headers = http::HeaderMap::new();
headers.insert("x-from-headers", http::HeaderValue::from_static("yes"));

let mut stream: ServerStream<_, StringValueView<'static>> = ServerStream {
headers: http::HeaderMap::new(),
headers,
body: Full::new(body.freeze()),
buf: BytesMut::new(),
encoding: None,
Expand Down Expand Up @@ -4459,12 +4465,17 @@ mod tests {
.contains("malformed Connect END_STREAM JSON"),
"unexpected error: {err}"
);
assert_eq!(err.response_headers().get("x-from-headers").unwrap(), "yes");

let again = stream
.message()
.await
.expect_err("malformed END_STREAM error must be sticky");
assert_eq!(again.code, ErrorCode::Internal);
assert_eq!(
again.response_headers().get("x-from-headers").unwrap(),
"yes"
);
}

/// Same contract for gRPC: an error in HTTP/2 trailers is a failed RPC
Expand Down
Loading