Skip to content

Conversation

@adriansmares
Copy link

@adriansmares adriansmares commented Feb 28, 2024

References mitchellh#278

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 mitchellh#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. Please also take a look at the comments in the original PR.

@adriansmares adriansmares changed the title Fix/typed nil hook Fix typed nil hook support Feb 28, 2024
@adriansmares adriansmares marked this pull request as ready for review February 28, 2024 18:28
@sagikazarmark
Copy link
Member

Thanks for the PR @adriansmares !

Would you mind rebasing your branch to resolve the conflicts?

I'll take a look at this PR later this week.

@sagikazarmark sagikazarmark self-requested a review August 11, 2024 22:13
@sagikazarmark sagikazarmark added this to the v2.2.0 milestone Aug 11, 2024
@sagikazarmark sagikazarmark modified the milestones: v2.2.0, v2.3.0 Sep 20, 2024
@sagikazarmark
Copy link
Member

@adriansmares, apologies for dropping the ball on this.

We've made some changes around nil value handling in #42 and #45. Can you check how your changes related to those? I suspect they are related (although I didn't have time to properly check).

@adriansmares
Copy link
Author

Hi @sagikazarmark,

It seems that the linked PRs did indeed fix my long standing issue. After a rebase the test case passes without any changes to mapstructure itself.

Thanks !

@adriansmares adriansmares deleted the fix/typed-nil-hook branch November 18, 2024 23:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants