From 896c7d15c590c388f53de2d004f18a5f16912609 Mon Sep 17 00:00:00 2001 From: "gcp-cherry-pick-bot[bot]" <98988430+gcp-cherry-pick-bot[bot]@users.noreply.github.com> Date: Mon, 20 Jan 2025 08:05:08 +0000 Subject: [PATCH] log non fatal parsing errors (#11932) (#11949) * log non fatal parsing errors * log at the error level * add check for nil * add check for nil --------- Signed-off-by: Your Name Co-authored-by: Ammar Yasser Co-authored-by: Your Name Co-authored-by: Mariam Fahmy --- cmd/cli/kubectl-kyverno/commands/apply/command.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cmd/cli/kubectl-kyverno/commands/apply/command.go b/cmd/cli/kubectl-kyverno/commands/apply/command.go index 11174538b8..7de9013985 100644 --- a/cmd/cli/kubectl-kyverno/commands/apply/command.go +++ b/cmd/cli/kubectl-kyverno/commands/apply/command.go @@ -403,6 +403,11 @@ func (c *ApplyCommandConfig) loadPolicies(skipInvalidPolicies SkippedInvalidPoli } for _, policyYaml := range policyYamls { loaderResults, err := policy.Load(fs, "", policyYaml) + if loaderResults != nil && loaderResults.NonFatalErrors != nil { + for _, err := range loaderResults.NonFatalErrors { + log.Log.Error(err.Error, "Non-fatal parsing error for single document") + } + } if err != nil { continue } @@ -412,6 +417,11 @@ func (c *ApplyCommandConfig) loadPolicies(skipInvalidPolicies SkippedInvalidPoli } } else { loaderResults, err := policy.Load(nil, "", path) + if loaderResults != nil && loaderResults.NonFatalErrors != nil { + for _, err := range loaderResults.NonFatalErrors { + log.Log.Error(err.Error, "Non-fatal parsing error for single document") + } + } if err != nil { log.Log.V(3).Info("skipping invalid YAML file", "path", path, "error", err) } else {