-
Notifications
You must be signed in to change notification settings - Fork 214
Open
Labels
Description
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:
- Server responds without setting the default value A for a shape.
- Response is stored somewhere.
- Model update is rolled out to servers and clients; default value changes to B.
- 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.