Fixed the way we propagate optional fields, removing it when empty

This fix is required to reduce the noise on the log errors (it's a side effect of my previous change, however the bug was already there before my changes is just that it's now detected by tests).

This fix is a backport from 3.2