Skip to content

Server SDKs should serialize unset values for shapes that have default values #3339

@david-perez

Description

@david-perez

This is a SHOULD according to the spec:

All effective default values SHOULD be serialized. This ensures that messages are unambiguous and do not change during deserialization if the default value for a member changes after the message was serialized.

So, to expand on the problem, consider this order of events:

  1. Server responds without setting the default value A for a shape.
  2. Response is stored somewhere.
  3. Model update is rolled out to servers and clients; default value changes to B.
  4. Client deserializes response from 2, sees no value for shape, so it defaults to B.

If server user code uses builders, default values are always set and are hence serialized in the response. However, user code might construct the struct directly, and omit values for shapes that have @default, in which case the default value is not serialized.

As @rcoh suggested, a good fix for this would be to code-generate a pass in the serializer that recursively set default values prior to performing serialization.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingserverRust server SDK

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions