Skip to content

feat: export DefaultDecodeHook for composition#2141

Open
Solaris-star wants to merge 1 commit into
spf13:masterfrom
Solaris-star:fix/2139-export-default-decode-hooks
Open

feat: export DefaultDecodeHook for composition#2141
Solaris-star wants to merge 1 commit into
spf13:masterfrom
Solaris-star:fix/2139-export-default-decode-hooks

Conversation

@Solaris-star

Copy link
Copy Markdown

Summary

WithDecodeHook / DecodeHook replace Viper's built-in mapstructure hooks entirely. The default weak string-to-slice hook is unexported, so apps that add a custom hook silently lose duration/slice conversions and cannot restore them (#2139).

Fix

Export DefaultDecodeHook() and use it as the internal default so callers can compose:

WithDecodeHook(mapstructure.ComposeDecodeHookFunc(
    viper.DefaultDecodeHook(),
    myCustomHook,
))

Tests

go test . -count=1 -run TestDefaultDecodeHookComposable
# ok

Fixes #2139

WithDecodeHook / DecodeHook replace Viper's built-in duration and
weak string-to-slice hooks entirely. Export DefaultDecodeHook so apps
can compose custom hooks without silently losing those defaults (spf13#2139).

Fixes spf13#2139
@CLAassistant

CLAassistant commented Jul 23, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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.

Default decode hooks are not accessible when overriding DecodeHook

2 participants