From 51c824543bca2f25baa6596827cf4fad8f18dc2e Mon Sep 17 00:00:00 2001 From: johncming Date: Sat, 21 Mar 2020 20:05:19 +0800 Subject: [PATCH] fix bug missing an error. (#7020) Signed-off-by: johncming --- pkg/rulefmt/rulefmt.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/pkg/rulefmt/rulefmt.go b/pkg/rulefmt/rulefmt.go index 10b53f83b..1d6716beb 100644 --- a/pkg/rulefmt/rulefmt.go +++ b/pkg/rulefmt/rulefmt.go @@ -264,12 +264,22 @@ func Parse(content []byte) (*RuleGroups, []error) { var ( groups RuleGroups node ruleGroups + errs []error ) + err := yaml.Unmarshal(content, &groups) - _err := yaml.Unmarshal(content, &node) - if err != nil || _err != nil { - return nil, []error{err} + if err != nil { + errs = append(errs, err) } + err = yaml.Unmarshal(content, &node) + if err != nil { + errs = append(errs, err) + } + + if len(errs) > 0 { + return nil, errs + } + return &groups, groups.Validate(node) }