mitchellh / mapstructure

Go library for decoding generic map values into native Go structures and vice versa.
https://gist.github.com/mitchellh/90029601268e59a29e64e55bab1c5bdc
MIT License
7.93k stars 677 forks source link

Fix typed nil hook support #278

Closed adriansmares closed 9 months ago

adriansmares commented 2 years ago

Typed nils which are the result of a type decoding hook seem to result in incorrect decoding behavior. Specifically, the nil is turned into an actual value due to the way the nil check works, instead of preserving the nil. Previously we were returning just untyped nils but ever since https://github.com/mitchellh/mapstructure/pull/205 this seems to no longer be supported while chaining multiple hooks.

I've added a test which reproduces this issue, and a possible fix.

cc @mitchellh

adriansmares commented 1 year ago

Pinging @mitchellh .