fix(config): validate rules when [extend] is used (#1592)

This commit is contained in:
Richard Gomez authored and GitHub committed 2025-10-16 10:54:59 -05:00
1 parent 87d96295d6
commit d22371873b
5 files changed
+38 -15

No files matched your search

+3 -2
View File
@@ -219,7 +219,8 @@ func (vc *ViperConfig) Translate() (Config, error) {
}
}
if maxExtendDepth != extendDepth {
currentExtendDepth := extendDepth
if maxExtendDepth != currentExtendDepth {
// disallow both usedefault and path from being set
if c.Extend.Path != "" && c.Extend.UseDefault {
return Config{}, errors.New("unable to load config due to extend.path and extend.useDefault being set")
@@ -236,7 +237,7 @@ func (vc *ViperConfig) Translate() (Config, error) {
}
// Validate the rules after everything has been assembled (including extended configs).
if extendDepth == 0 {
if currentExtendDepth == 0 {
for _, rule := range c.Rules {
if err := rule.Validate(); err != nil {
return Config{}, err