Skip to content

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

Open
Hashim1999164 wants to merge 1 commit into
apple:mainfrom
Hashim1999164:fix/empty-text-plain-body
Open

Skip empty HTTPBody chunks in the URLSession stream bridge#96
Hashim1999164 wants to merge 1 commit into
apple:mainfrom
Hashim1999164:fix/empty-text-plain-body

Conversation

@Hashim1999164

@Hashim1999164 Hashim1999164 commented Aug 13, 2026

Copy link
Copy Markdown

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.

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

3 participants