From 80e37d9cab463d410befa94af2f4055695e18bcb Mon Sep 17 00:00:00 2001 From: Mike Mason Date: Wed, 7 Aug 2024 11:53:28 -0500 Subject: [PATCH] ensure validation errors include names for better context (#253) 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 970b9300..a095cafc 100644 --- a/internal/iapl/policy.go +++ b/internal/iapl/policy.go @@ -394,22 +394,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) } }