-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Open
Labels
kind/enhancementNew feature or requestNew feature or request
Description
Preflight Checklist
- I have searched the issue tracker for an issue that matches the one I want to file, without success.
Problem Description
Describe the feature
When using viper.WriteConfig or a custom write implementation (via marshalWriter), values in the internal config map like "true" (string) are written to the output file (e.g., YAML) as "true" instead of true (boolean).
This usually happens when config values are updated or set programmatically from sources that store everything as strings (e.g., CLI flags, env vars, encrypted configs, etc).
Problem
This causes configuration types to be misleading in output YAML:
packager:
example_project:
trust: "true" # should be: true (bool)
### Proposed Solution
A type normalization step before encoding, where "true" / "false" strings could be coerced into booleans (similarly for numeric strings).
A hook/callback mechanism (e.g., BeforeMarshal(func(map[string]any) map[string]any)) so users can implement normalization logic themselves before Viper marshals the config.
An option or flag like viper.NormalizeTypesOnWrite(true) that opts into this behavior.
### Alternatives Considered
_No response_
### Additional Information
_No response_Metadata
Metadata
Assignees
Labels
kind/enhancementNew feature or requestNew feature or request