Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[enhancement] Add check for reflect.Value in ComposeDecodeHookFunc #52

Merged
merged 3 commits into from
Nov 18, 2024

Conversation

mahadzaryab1
Copy link

This is a follow-up PR to #37. In this PR, we add a check to ComposeDecodeHookFunc to see if the data obtained from the hook is of type reflect.Value. If it is, then we don't make an additional reflect.ValueOf call. This allows us to not drop into the "value" space which is helpful when decoding nil values as they panic when going from reflect.Value to a value via .Interface().

Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
Copy link

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, this should address my original use case without introducing a new hook API (which I still thing is a worthy thing to do, e.g. there is a similar issue #21)

@mahadzaryab1 mahadzaryab1 marked this pull request as ready for review November 17, 2024 21:58
@mahadzaryab1
Copy link
Author

@sagikazarmark Are you able to take a look at this?

Copy link
Member

@sagikazarmark sagikazarmark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@sagikazarmark sagikazarmark merged commit 2cb620d into go-viper:main Nov 18, 2024
8 checks passed
@sagikazarmark
Copy link
Member

Thanks @mahadzaryab1!

Can you verify that the latest main works for your use cases in OTEL?

Also, I wouldn't mind fixing #49 before cutting a new release, I'm just not sure yet what the right fix is, but I suspect simply reverting the error message should work.

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.

3 participants