diff --git a/internals/plan/extensions_test.go b/internals/plan/extensions_test.go index 2cbd8b86..dd56b6af 100644 --- a/internals/plan/extensions_test.go +++ b/internals/plan/extensions_test.go @@ -190,7 +190,7 @@ var extensionTests = []struct { a: a b: b`, }}, - error: "cannot validate layer section .* cannot accept entry not starting .*", + error: ".*cannot accept entry not starting.*", }, { summary: "Load file layers with section validation failure #2", extensions: []extension{{ @@ -209,7 +209,7 @@ var extensionTests = []struct { x-field: x1:`, }}, - error: "cannot validate layer section .* cannot have nil entry .*", + error: ".*cannot have nil entry.*", }, { summary: "Load file layers failed plan validation", extensions: []extension{{ @@ -244,7 +244,7 @@ var extensionTests = []struct { a: a b: b`, }}, - error: "cannot validate plan section .* cannot find .* as required by .*", + error: ".*cannot find.*", }, { summary: "Check empty section omits entry", extensions: []extension{{ diff --git a/internals/plan/plan.go b/internals/plan/plan.go index df5a54af..b625eee4 100644 --- a/internals/plan/plan.go +++ b/internals/plan/plan.go @@ -954,10 +954,10 @@ func (layer *Layer) Validate() error { } } - for field, section := range layer.Sections { + for _, section := range layer.Sections { err := section.Validate() if err != nil { - return fmt.Errorf("cannot validate layer section %q: %w", field, err) + return err } } @@ -1055,10 +1055,10 @@ func (p *Plan) Validate() error { } // Each section extension must validate the combined plan. - for field, extension := range sectionExtensions { + for _, extension := range sectionExtensions { err = extension.ValidatePlan(p) if err != nil { - return fmt.Errorf("cannot validate plan section %q: %w", field, err) + return err } }