Skip to content

Emit empty payload for RPC protocol event encoding#1245

Merged
sugmanue merged 2 commits into
smithy-lang:mainfrom
sugmanue:sugmanue/event-stream-fix
Jun 16, 2026
Merged

Emit empty payload for RPC protocol event encoding#1245
sugmanue merged 2 commits into
smithy-lang:mainfrom
sugmanue:sugmanue/event-stream-fix

Conversation

@sugmanue

Copy link
Copy Markdown
Contributor

What behavior changes?

RPC protocols (awsJson, rpcv2-cbor) now emit an empty payload (e.g., {}) and set the content-type header for events with no payload members. REST protocol (restJson) continue to omit the body and content-type as before.

Why is this change needed?

RPC protocols must always serialize a body even when there are no payload members, unlike REST protocols which omit it.

How was this validated?

  • Existing unit tests pass. Compilation verified across all affected modules.
  • Tested against the internal server using REST and RPCv2

What should reviewers focus on?

  • The consolidated condition in EventSerializer.writeStruct (emitEmptyPayload || hasPayloadMembers)
  • Correct true/false values passed at each protocol call site

Additional Links


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Add emitEmptyPayload flag so RPC protocols (awsJson, rpcv2-cbor) serialize
an empty body and set content-type when there are no payload members, while
REST protocols continue to omit both.
@sugmanue sugmanue enabled auto-merge (squash) June 16, 2026 02:14
Add forInputStream/forOutputStream overloads without emitEmptyPayload
parameter, defaulting to false (REST behavior) for backwards compatibility.
@sugmanue sugmanue merged commit 6832af2 into smithy-lang:main Jun 16, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants