JSON PATCH: I thought nullable DTO fields were enough
I thought nullable DTO fields were enough for PATCH.
My rule was simple: if a field is missing or null, treat both the same. Client sends only what it wants to update.
That worked until it didn’t
We accidentally wiped a production value because the client updated one field and omitted another intentionally. :(
After deserialization, I couldn’t distinguish “not sent” from “explicit null,” so my code cleared a field that should have stayed untouched. So we had to roll back. No problem
I am looking at a few alternatives like nullable fields, explicit field_present flags, JSON Patch, and wrapper types that preserve field presence.
Curious how other people handle “missing vs null” in PATCH without making the client payload ugly?