From 5a8df9d6885b61a2ecafc855a6e2f3399736e0fb Mon Sep 17 00:00:00 2001 From: Xe Iaso Date: Sat, 25 Oct 2025 01:19:35 +0000 Subject: [PATCH] fix(policy/checker): more explicit short-circuit Signed-off-by: Xe Iaso --- lib/policy/checker/checker.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/policy/checker/checker.go b/lib/policy/checker/checker.go index 5c76d97a..31551cd9 100644 --- a/lib/policy/checker/checker.go +++ b/lib/policy/checker/checker.go @@ -20,8 +20,6 @@ type List []Impl // It returns true only if *all* checkers return true (AND semantics). // If any checker returns an error, the function returns false and the error. func (l List) Check(r *http.Request) (bool, error) { - // Assume success until a checker says otherwise. - allOk := true for _, c := range l { ok, err := c.Check(r) if err != nil { @@ -31,11 +29,11 @@ func (l List) Check(r *http.Request) (bool, error) { if !ok { // One false means the combined result is false. Short-circuit // so we don't waste time. - allOk = false - break + return false, err } } - return allOk, nil + // Assume success until a checker says otherwise. + return true, nil } func (l List) Hash() string {