Skip to content

Skip empty HTTPBody chunks in the URLSession stream bridge - #96

Merged
guoye-zhang merged 2 commits into
apple:mainfrom
Hashim1999164:fix/empty-text-plain-body
Sep 28, 2026
Merged

guoye-zhang merged 2 commits into
apple:mainfrom
Hashim1999164:fix/empty-text-plain-body

Conversation

@Hashim1999164

@Hashim1999164 Hashim1999164 commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #85

An empty text/plain request body vends a zero length chunk. The output stream bridge then tried to write that chunk and hit a precondition. Maintainers agreed the transport should send an empty body.

Empty chunks are now skipped so the stream closes with a zero length body instead of crashing.

Test plan

Added testHTTPBodyOutputStreamEmptyChunkDoesNotCrash covering a single empty chunk. Built the OpenAPIURLSession product. Full XCTest suite needs Xcode.

@guoye-zhang guoye-zhang added the 🔨 semver/patch No public API change. label Aug 13, 2026
@guoye-zhang

Copy link
Copy Markdown
Contributor

@czechboy0 Based on the discussion in #85, should we work around the assert here or make it impossible to vend an empty chunk from the runtime?

@czechboy0

Copy link
Copy Markdown
Contributor

We need to make it legal to send an empty chunk, but exactly how that should be done here I'd defer to @simonjbeaumont and you about. We definitely can't add a new requirement into Runtime, as it could break some adopters who use empty chunks already with other transports.

@Hashim1999164

Copy link
Copy Markdown
Contributor Author

saw the thread. this PR only skips empty chunks in the URLSession bridge so the assert does not fire. if yall want empty chunks to stay legal somewhere else in Runtime that is above my pay grade, bro i dont know that lmao. happy to tweak this transport side if you land on a preferred approach.

@Hashim1999164

Copy link
Copy Markdown
Contributor Author

@guoye-zhang any update? this one's approved and green on my side, wondering if it's waiting on anything else

@guoye-zhang
guoye-zhang enabled auto-merge (squash) September 28, 2026 04:37
@guoye-zhang
guoye-zhang merged commit 77effea into apple:main Sep 28, 2026
42 of 44 checks passed
@timbms

timbms commented Sep 30, 2026

Copy link
Copy Markdown

Great. When will this PR be released?

@guoye-zhang

Copy link
Copy Markdown
Contributor

Released as 1.3.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 semver/patch No public API change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crash when sending empty text/plain request body (precondition(!bytesToWrite.isEmpty)) for generated client operation

4 participants