From ecfe9f509ffacb3af7d747e0e5a2ead7fcaf1d69 Mon Sep 17 00:00:00 2001 From: Joseph Phillips Date: Wed, 18 Sep 2024 16:38:57 +0200 Subject: [PATCH] chore: explicitly check for NotFound We shouldn't rely on the fact that a callee only returns NotFound to pun err != nil. Instead, explicitly handle NotFound and throw out for other error types. --- worker/uniter/relation/resolver.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/worker/uniter/relation/resolver.go b/worker/uniter/relation/resolver.go index 6d2021deea66..2685d804657e 100644 --- a/worker/uniter/relation/resolver.go +++ b/worker/uniter/relation/resolver.go @@ -114,6 +114,8 @@ func (r *relationsResolver) NextOp( return nil, resolver.ErrNoOperation } +// processRelationSnapshot reconciles the local and remote states for a +// single relation and determines what hoof (if any) should be fired. func (r *relationsResolver) processRelationSnapshot( relationID int, relationSnapshot remotestate.RelationSnapshot, @@ -139,6 +141,9 @@ func (r *relationsResolver) processRelationSnapshot( // to be fired for this relation. relState, err := r.stateTracker.State(relationID) if err != nil { + if !errors.Is(err, errors.NotFound) { + return nil, errors.Trace(err) + } relState = NewState(relationID) } hInfo, err := r.nextHookForRelation(relState, relationSnapshot, remoteBroken)