-
Notifications
You must be signed in to change notification settings - Fork 40
Open
Labels
kind/bugFeature doesn't work as expected.Feature doesn't work as expected.status/triageCollecting information required to triage the issue.Collecting information required to triage the issue.
Description
Description
Summary
When a generated Swift OpenAPI client sends an empty string as a text/plain request body, the request crashes at runtime with:
Precondition failed: writePendingBytes(_:) must be called with non-empty bytes
This appears to come from the OpenAPI runtime/URLSession transport path (HTTPBodyOutputStreamBridge).
Actual behavior
App crashes with precondition failure:
writePendingBytes(_:) must be called with non-empty bytes.
Reproduction
OpenAPI snippet
paths:
/items/{itemname}:
post:
operationId: sendItemCommand
parameters:
- name: itemname
in: path
required: true
schema:
type: string
requestBody:
required: true
content:
text/plain:
schema:
type: string
responses:
"200":
description: OKlet path = Operations.sendItemCommand.Input.Path(itemname: "MyItem")
let body = Operations.sendItemCommand.Input.Body.plainText(.init(""))
let query = Operations.sendItemCommand.Input.Query()
_ = try await client.sendItemCommand(path: path, query: query, body: body)Package version(s)
swift-openapi-runtime: 1.8.0
swift-openapi-urlsession: 1.0.2
Expected behavior
No crash.
Either:
- send a valid request with Content-Length: 0, or
- return a normal thrown error if empty body is unsupported.
Environment
Xcode: 26.3 (17C529)
swift-openapi-runtime: 1.8.0
swift-openapi-urlsession: 1.0.2
Generated by swift-openapi-generator
Additional information
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
kind/bugFeature doesn't work as expected.Feature doesn't work as expected.status/triageCollecting information required to triage the issue.Collecting information required to triage the issue.