Repository navigation
Replies: 1 comment 1 reply
|
I'll assume you closed this because you realized it does in fact act the way you requested. Because IIRC messagepack's object resolver produces formatters that will be happy to skip missing fields. |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Problem
When deserializing older MessagePack payloads into newer DTOs, deserialization fails if a new non-nullable value-type member is added.
Example:
Even though int has a valid CLR default (0), MessagePack does not fall back to it when the key is missing / nil.
Motivation
In many real systems (microservices, rolling deployments, cached payloads), this makes forward-compatible schema evolution harder and forces either:
Making many members nullable (int?)
Writing custom formatters per member
Both add boilerplate when 0 is a valid semantic default.
Request
Introduce an opt-in way to allow default value fallback for missing or nil members, for example:
Serializer option
Behavior:
If member is missing or nil
And target type is non-nullable value type
Assign default(T) instead of throwing
Notes
Fully opt-in
No wire format change
Does not affect strict behavior by default
Similar to how Protobuf handles missing fields
All reactions