From ba1025ba31e3ce09139e55b25557d0cc0358edc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89mile=20R=C3=A9?= Date: Fri, 15 May 2026 11:22:56 +0400 Subject: [PATCH] Propagate errors from resolveThirdParty MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, resolveThirdParty silently swallowed all errors from LoadByOrganizationIDAndCommonThirdPartyID, making real database errors indistinguishable from a missing third party. Now it returns an error for non-not-found failures, wrapped for clarity, and callers log and degrade gracefully. Signed-off-by: Émile Ré --- pkg/probo/tracker_mapping_worker.go | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/pkg/probo/tracker_mapping_worker.go b/pkg/probo/tracker_mapping_worker.go index ec6a03c29..9541f098f 100644 --- a/pkg/probo/tracker_mapping_worker.go +++ b/pkg/probo/tracker_mapping_worker.go @@ -118,7 +118,12 @@ func (h *trackerMappingHandler) matchByPattern( var thirdPartyID *gid.GID if commonPattern.CommonThirdPartyID != nil { - thirdPartyID = h.resolveThirdParty(ctx, conn, tp, &commonPattern) + var err error + thirdPartyID, err = h.resolveThirdParty(ctx, conn, tp, &commonPattern) + if err != nil { + h.logger.ErrorCtx(ctx, "cannot resolve third party from pattern match", log.Error(err)) + return nil, nil + } } return &commonPattern.ID, thirdPartyID @@ -165,7 +170,11 @@ func (h *trackerMappingHandler) matchByDomain( } commonPattern.ID = actualID - thirdPartyID := h.resolveThirdParty(ctx, tx, tp, &commonPattern) + thirdPartyID, err := h.resolveThirdParty(ctx, tx, tp, &commonPattern) + if err != nil { + h.logger.ErrorCtx(ctx, "cannot resolve third party from domain match", log.Error(err)) + return &commonPattern.ID, nil + } return &commonPattern.ID, thirdPartyID } @@ -175,9 +184,9 @@ func (h *trackerMappingHandler) resolveThirdParty( conn pg.Querier, tp coredata.TrackerPattern, commonPattern *coredata.CommonTrackerPattern, -) *gid.GID { +) (*gid.GID, error) { if commonPattern.CommonThirdPartyID == nil { - return nil + return nil, nil } scope := coredata.NewScopeFromObjectID(tp.ID) @@ -190,8 +199,11 @@ func (h *trackerMappingHandler) resolveThirdParty( tp.OrganizationID, *commonPattern.CommonThirdPartyID, ); err != nil { - return nil + if errors.Is(err, coredata.ErrResourceNotFound) { + return nil, nil + } + return nil, fmt.Errorf("cannot resolve third party: %w", err) } - return &t.ID + return &t.ID, nil }