If valDecoder fails on a null value, then the fallback is used as if the field were missing entirely.
So that makes sense, since an empty record apparently doesn't fail on null. But from reading the code it seems Json.Decode.oneOf [ Json.Decode.null fallback, decoder ] should decode null to fallback.
Consider the code
and the json:
and:
They should be both decoded into:
but the first one (with null) is decode into:
It seems the culprit is Json.Decode.Pipeline.optional. As the docs says:
So that makes sense, since an empty record apparently doesn't fail on null. But from reading the code it seems
Json.Decode.oneOf [ Json.Decode.null fallback, decoder ]
should decode null to fallback.Anyway it needs a solution.