Skip to content

Implicit event stream payload members#4535

Merged
ysaito1001 merged 4 commits intomainfrom
fahadzub/implicit
Feb 13, 2026
Merged

Implicit event stream payload members#4535
ysaito1001 merged 4 commits intomainfrom
fahadzub/implicit

Conversation

@drganjoo
Copy link
Contributor

Summary

  • Fix response payload ownership for operations with distinct input/output stream types
  • Handle implicit event payload members (members with neither @eventHeader nor @eventPayload)

Ownership

payloadMetadata() used operationShape.isInputEventStream(model) to determine takesOwnership for both request and response serializers. For operations where the input has a @streaming event stream but the output has a non-streaming union payload, the response serializer incorrectly generated fn(payload: Option<T>) (owned), then passed the owned value to a function expecting &T.

For example:

  operation DuplexStreamWithDistinctStreams {
      input: DuplexInput
      output: DuplexOutput
  }

  structure DuplexInput {
      @httpPayload
      stream: EventStream        // @streaming union
  }

  structure DuplexOutput {
      @httpPayload
      stream: SingletonStream    // non-streaming union
  }

The response serializer checked isInputEventStream (true, because of EventStream) to decide ownership for the output's SingletonStream, causing a type mismatch in the generated Rust.

Fix: Check isInputEventStream for requests and isOutputEventStream for responses.

Implicit Payload

Per the https://smithy.io/2.0/spec/streaming.html#eventpayload-trait, event struct members with neither @eventHeader nor @eventPayload are collectively serialized as a protocol-specific document in the message body. The unmarshaller handled @eventHeader and @eventPayload members but never parsed the body for these implicit members, leaving their set_* builder methods as dead code (fails with -D warnings).

There are three valid member combinations in an event struct:

│               Case                │                 Example                  │                          Handled by                          │
├───────────────────────────────────┼──────────────────────────────────────────┼──────────────────────────────────────────────────────────────┤
│ All @eventPayload/@eventHeader    │ @eventHeader header + @eventPayload data │ renderUnmarshallEventPayload + renderUnmarshallEventHeader   │
├───────────────────────────────────┼──────────────────────────────────────────┼──────────────────────────────────────────────────────────────┤
│ No traits on any member           │ fieldA + fieldB (all implicit)           │ payloadOnly branch — parses entire body as protocol document │
├───────────────────────────────────┼──────────────────────────────────────────┼──────────────────────────────────────────────────────────────┤
│ @eventHeader + trait-less members │ @eventHeader header + payload (implicit) │ Was broken — headers parsed, body ignored                    │
└───────────────────────────────────┴──────────────────────────────────────────┴──────────────────────────────────────────────────────────────┘

For case 3, the wire format looks like:
Event stream message headers:

    header = "my-header-value"          <-- from @eventHeader

Event stream message body (JSON):

    {"payload": "my-payload-value"}     <-- implicit members as JSON document

Fix: In the else branch, after handling @eventPayload and @eventHeader members, detect implicit members and parse them from the message body using the existing structure parser into the builder.

@drganjoo drganjoo requested review from a team as code owners February 12, 2026 23:21
@github-actions
Copy link

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • No codegen difference in the Client Test
  • Server Test (ignoring whitespace)
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

Copy link

@jlizen jlizen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@github-actions
Copy link

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • No codegen difference in the Client Test
  • Server Test (ignoring whitespace)
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@ysaito1001 ysaito1001 mentioned this pull request Feb 13, 2026
5 tasks
@github-actions
Copy link

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • No codegen difference in the Client Test
  • Server Test (ignoring whitespace)
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@ysaito1001 ysaito1001 enabled auto-merge February 13, 2026 21:27
@github-actions
Copy link

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • No codegen difference in the Client Test
  • Server Test (ignoring whitespace)
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@ysaito1001 ysaito1001 merged commit e371005 into main Feb 13, 2026
92 of 94 checks passed
@ysaito1001 ysaito1001 deleted the fahadzub/implicit branch February 13, 2026 22:33
ysaito1001 added a commit that referenced this pull request Feb 16, 2026
## Motivation and Context
P382257849

## Description
Changes on the client side:
- [x] Remove extra rest json tests that are officially part of Smithy
protocol tests in 1.64.0
- [x] Filter out newly added model in `SmithyTypesPubUseExtraTest.kt`
that would otherwise defeat the purpose of the test

Changes on the server side:
- [x] Address errors related to server's constraint types
(#4506)
- [x] #4535
- [x] #4537 

## Testing
- CI

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._

---------

Co-authored-by: Fahad Zubair <fahadzubair@gmail.com>
Co-authored-by: Fahad Zubair <fahadzub@amazon.com>
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.

4 participants