From 00c4033e6eb37a3d471035e775e1c71be17ca352 Mon Sep 17 00:00:00 2001 From: Mike Mason Date: Tue, 7 May 2024 16:39:54 -0500 Subject: [PATCH] ensure validation errors include names for better context Signed-off-by: Mike Mason --- internal/iapl/policy.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/iapl/policy.go b/internal/iapl/policy.go index 12f4f51d..9a43a5fa 100644 --- a/internal/iapl/policy.go +++ b/internal/iapl/policy.go @@ -387,22 +387,22 @@ func (v *policy) validateActionBindings() error { } if _, ok := bindingMap[key]; ok { - return fmt.Errorf("%d: %w", i, ErrorActionBindingExists) + return fmt.Errorf("%d (%s:%s): %w", i, binding.TypeName, binding.ActionName, ErrorActionBindingExists) } bindingMap[key] = struct{}{} if _, ok := v.ac[binding.ActionName]; !ok { - return fmt.Errorf("%d: %s: %w", i, binding.ActionName, ErrorUnknownAction) + return fmt.Errorf("%d (%s:%s): %s: %w", i, binding.TypeName, binding.ActionName, binding.ActionName, ErrorUnknownAction) } rt, ok := v.rt[binding.TypeName] if !ok { - return fmt.Errorf("%d: %s: %w", i, binding.TypeName, ErrorUnknownType) + return fmt.Errorf("%d (%s:%s): %s: %w", i, binding.TypeName, binding.ActionName, binding.TypeName, ErrorUnknownType) } if err := v.validateConditions(rt, binding.Conditions); err != nil { - return fmt.Errorf("%d: conditions: %w", i, err) + return fmt.Errorf("%d (%s:%s): conditions: %w", i, binding.TypeName, binding.ActionName, err) } }