From 4b8425c1acc60c4adfecb701ac7b565beaee1d23 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Thu, 10 Sep 2026 02:23:14 -0600 Subject: [PATCH] fix(ippolicy): return empty evaluator on load failure --- net/ippolicy/policy.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/net/ippolicy/policy.go b/net/ippolicy/policy.go index bf4ec51..070a13d 100644 --- a/net/ippolicy/policy.go +++ b/net/ippolicy/policy.go @@ -119,14 +119,21 @@ func (p *Policy) Current() *Evaluator { return p.current.Load() } // Refresh errors are returned while the previous evaluator is retained. func (p *Policy) Load(ctx context.Context, wait bool) (*Evaluator, error) { if _, err := p.Revalidate(ctx); err != nil { - return p.Current(), err + return p.lastGood(), err } if p.loadedAt.Load() == nil || wait { if err := p.refresh.Wait(ctx); err != nil { - return p.Current(), err + return p.lastGood(), err } } - return p.Current(), nil + return p.lastGood(), nil +} + +func (p *Policy) lastGood() *Evaluator { + if evaluator := p.Current(); evaluator != nil { + return evaluator + } + return &Evaluator{} } func (p *Policy) Due(ctx context.Context) (bool, error) {